transformer
Bases: rpn
Transformer model implemented as the RPN model.
This class defines a transformer architecture with bilinear interdependence layers, perceptron layers, and fully connected layers. It supports various customization options for data transformation, parameter reconciliation, output processing, and interdependence functions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dims
|
list[int] | tuple[int]
|
A list or tuple of integers representing the dimensions of the bilinear interdependence layers. Must contain at least two dimensions. |
required |
fc_dims
|
list[int] | tuple[int]
|
A list or tuple of integers representing the dimensions of the fully connected layers. Must contain at least one dimension. |
required |
batch_num
|
int
|
The batch size for bilinear interdependence layers. Default is None. |
None
|
name
|
str
|
The name of the transformer model. Default is 'rpn_transformer'. |
'rpn_transformer'
|
channel_num
|
int
|
The number of channels for each layer. Default is 1. |
1
|
width
|
int
|
The number of parallel heads in each layer. Default is 1. |
1
|
with_dual_lphm_interdependence
|
bool
|
If True, enables dual low-parametric high-order interdependence. Default is False. |
False
|
with_lorr_interdependence
|
bool
|
If True, enables low-rank parameterized interdependence. Default is True. |
True
|
r_interdependence
|
int
|
Rank parameter for low-rank interdependence. Default is 3. |
3
|
with_taylor
|
bool
|
If True, enables Taylor series-based data transformation. Default is False. |
False
|
d
|
int
|
Degree of Taylor series expansion. Default is 2. |
2
|
with_dual_lphm
|
bool
|
If True, enables dual low-parametric high-order parameter reconciliation. Default is False. |
False
|
with_lorr
|
bool
|
If True, enables low-rank parameterized reconciliation. Default is False. |
False
|
r
|
int
|
Rank parameter for low-rank reconciliation. Default is 3. |
3
|
enable_bias
|
bool
|
If True, enables bias in the layers. Default is True. |
True
|
with_residual
|
bool
|
If True, adds residual connections to the layers. Default is True. |
True
|
with_batch_norm
|
bool
|
If True, applies batch normalization after each layer. Default is True. |
True
|
with_relu
|
bool
|
If True, applies ReLU activation after each layer. Default is True. |
True
|
with_softmax
|
bool
|
If True, applies Softmax activation at the output layer. Default is True. |
True
|
with_dropout
|
bool
|
If True, applies dropout regularization. Default is True. |
True
|
p
|
float
|
Dropout probability. Default is 0.25. |
0.25
|
device
|
str
|
Device to perform computations ('cpu' or 'cuda'). Default is 'cpu'. |
'cpu'
|
*args
|
optional
|
Additional positional arguments for the superclass. |
()
|
**kwargs
|
optional
|
Additional keyword arguments for the superclass. |
{}
|
Raises:
Type | Description |
---|---|
ValueError
|
If |
Methods:
Name | Description |
---|---|
__init__ |
Initializes the transformer model with the specified parameters. |
Source code in tinybig/model/rpn_transformer.py
21 22 23 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 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
|
__init__(dims, fc_dims, batch_num=None, name='rpn_transformer', channel_num=1, width=1, with_dual_lphm_interdependence=False, with_lorr_interdependence=True, r_interdependence=3, with_taylor=False, d=2, with_dual_lphm=False, with_lorr=False, r=3, enable_bias=True, with_residual=True, with_batch_norm=True, with_relu=True, with_softmax=True, with_dropout=True, p=0.25, device='cpu', *args, **kwargs)
Initialize the transformer model as the RPN model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dims
|
list[int] | tuple[int]
|
A list or tuple of integers representing the dimensions of the bilinear interdependence layers. Must contain at least two dimensions. |
required |
fc_dims
|
list[int] | tuple[int]
|
A list or tuple of integers representing the dimensions of the fully connected layers. Must contain at least one dimension. |
required |
batch_num
|
int
|
The batch size for bilinear interdependence layers. Default is None. |
None
|
name
|
str
|
The name of the transformer model. Default is 'rpn_transformer'. |
'rpn_transformer'
|
channel_num
|
int
|
The number of channels for each layer. Default is 1. |
1
|
width
|
int
|
The number of parallel heads in each layer. Default is 1. |
1
|
with_dual_lphm_interdependence
|
bool
|
If True, enables dual low-parametric high-order interdependence. Default is False. |
False
|
with_lorr_interdependence
|
bool
|
If True, enables low-rank parameterized interdependence. Default is True. |
True
|
r_interdependence
|
int
|
Rank parameter for low-rank interdependence. Default is 3. |
3
|
with_taylor
|
bool
|
If True, enables Taylor series-based data transformation. Default is False. |
False
|
d
|
int
|
Degree of Taylor series expansion. Default is 2. |
2
|
with_dual_lphm
|
bool
|
If True, enables dual low-parametric high-order parameter reconciliation. Default is False. |
False
|
with_lorr
|
bool
|
If True, enables low-rank parameterized reconciliation. Default is False. |
False
|
r
|
int
|
Rank parameter for low-rank reconciliation. Default is 3. |
3
|
enable_bias
|
bool
|
If True, enables bias in the layers. Default is True. |
True
|
with_residual
|
bool
|
If True, adds residual connections to the layers. Default is True. |
True
|
with_batch_norm
|
bool
|
If True, applies batch normalization after each layer. Default is True. |
True
|
with_relu
|
bool
|
If True, applies ReLU activation after each layer. Default is True. |
True
|
with_softmax
|
bool
|
If True, applies Softmax activation at the output layer. Default is True. |
True
|
with_dropout
|
bool
|
If True, applies dropout regularization. Default is True. |
True
|
p
|
float
|
Dropout probability. Default is 0.25. |
0.25
|
device
|
str
|
Device to perform computations ('cpu' or 'cuda'). Default is 'cpu'. |
'cpu'
|
*args
|
optional
|
Additional positional arguments for the superclass. |
()
|
**kwargs
|
optional
|
Additional keyword arguments for the superclass. |
{}
|
Raises:
Type | Description |
---|---|
ValueError
|
If |
Source code in tinybig/model/rpn_transformer.py
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 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
|