perceptron_layer
Bases: layer
A layer consisting of perceptron heads.
This layer uses perceptron heads with optional data expansion, parameter reconciliation, and output processing.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
m
|
int
|
The input dimension of the perceptron heads. |
required |
n
|
int
|
The output dimension of the perceptron heads. |
required |
name
|
str
|
The name of the layer. |
'perceptron_layer'
|
channel_num
|
int
|
The number of channels in the layer. |
1
|
width
|
int
|
The number of perceptron heads in the layer. |
1
|
with_bspline
|
bool
|
Whether to use B-spline expansion. |
False
|
with_taylor
|
bool
|
Whether to use Taylor expansion. |
False
|
d
|
int
|
The degree of expansion when using Taylor or B-spline expansion. |
2
|
with_hybrid_expansion
|
bool
|
Whether to use hybrid expansion. |
False
|
with_dual_lphm
|
bool
|
Whether to use dual LPHM reconciliation. |
False
|
with_lorr
|
bool
|
Whether to use LORR reconciliation. |
False
|
r
|
int
|
The rank for parameter reconciliation. |
3
|
enable_bias
|
bool
|
Whether to enable bias in parameter reconciliation. |
True
|
with_residual
|
bool
|
Whether to include a residual connection. |
False
|
with_batch_norm
|
bool
|
Whether to apply batch normalization. |
False
|
with_relu
|
bool
|
Whether to apply ReLU activation. |
True
|
with_dropout
|
bool
|
Whether to apply dropout. |
True
|
p
|
float
|
Dropout probability. |
0.5
|
with_softmax
|
bool
|
Whether to apply softmax activation. |
True
|
parameters_init_method
|
str
|
The method for parameter initialization. |
'xavier_normal'
|
device
|
str
|
The device to run the layer on ('cpu' or 'cuda'). |
'cpu'
|
Returns:
Type | Description |
---|---|
perceptron_layer
|
An initialized perceptron layer with the specified configuration. |
Source code in tinybig/layer/basic_layers.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
|
__init__(m, n, name='perceptron_layer', channel_num=1, width=1, with_bspline=False, with_taylor=False, d=2, with_hybrid_expansion=False, with_dual_lphm=False, with_lorr=False, r=3, enable_bias=True, with_residual=False, with_batch_norm=False, with_relu=True, with_dropout=True, p=0.5, with_softmax=True, parameters_init_method='xavier_normal', device='cpu', *args, **kwargs)
Initialize a perceptron layer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
m
|
int
|
The input dimension of the perceptron heads. |
required |
n
|
int
|
The output dimension of the perceptron heads. |
required |
name
|
str
|
The name of the layer. |
'perceptron_layer'
|
channel_num
|
int
|
The number of channels in the layer. |
1
|
width
|
int
|
The number of perceptron heads in the layer. |
1
|
with_bspline
|
bool
|
Whether to use B-spline expansion. |
False
|
with_taylor
|
bool
|
Whether to use Taylor expansion. |
False
|
d
|
int
|
The degree of expansion when using Taylor or B-spline expansion. |
2
|
with_hybrid_expansion
|
bool
|
Whether to use hybrid expansion. |
False
|
with_dual_lphm
|
bool
|
Whether to use dual LPHM reconciliation. |
False
|
with_lorr
|
bool
|
Whether to use LORR reconciliation. |
False
|
r
|
int
|
The rank for parameter reconciliation. |
3
|
enable_bias
|
bool
|
Whether to enable bias in parameter reconciliation. |
True
|
with_residual
|
bool
|
Whether to include a residual connection. |
False
|
with_batch_norm
|
bool
|
Whether to apply batch normalization. |
False
|
with_relu
|
bool
|
Whether to apply ReLU activation. |
True
|
with_dropout
|
bool
|
Whether to apply dropout. |
True
|
p
|
float
|
Dropout probability. |
0.5
|
with_softmax
|
bool
|
Whether to apply softmax activation. |
True
|
parameters_init_method
|
str
|
The method for parameter initialization. |
'xavier_normal'
|
device
|
str
|
The device to run the layer on ('cpu' or 'cuda'). |
'cpu'
|
Returns:
Type | Description |
---|---|
None
|
|
Source code in tinybig/layer/basic_layers.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
|