regression_rnn
Bases: rpn
A Recurrent Neural Network (RNN) model for regression tasks, implemented as the RPN model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
chain_length
|
int
|
The length of the chain structure used in the RNN layers. |
required |
dims
|
list[int] | tuple[int]
|
A list or tuple of integers representing the dimensions of each layer in the model. Must contain at least two dimensions. |
required |
name
|
str
|
The name of the RNN model. Default is 'rpn_rnn'. |
'rpn_rnn'
|
channel_num
|
int
|
The number of channels in each layer. Default is 1. |
1
|
width
|
int
|
The number of parallel heads in each layer. Default is 1. |
1
|
bi_directional
|
bool
|
If True, enables bidirectional processing in the chain structure. Default is False. |
False
|
with_multihop
|
bool
|
If True, enables multi-hop interdependence in the chain structure. Default is False. |
False
|
h
|
int
|
The number of hops for multi-hop interdependence. Default is 1. |
1
|
accumulative
|
bool
|
If True, accumulates multi-hop dependencies. Default is False. |
False
|
with_inverse_approx
|
bool
|
If True, enables inverse approximation for chain interdependence. Default is False. |
False
|
with_exponential_approx
|
bool
|
If True, enables exponential approximation for chain interdependence. Default is False. |
False
|
self_dependence
|
bool
|
If True, enables self-dependence in the chain structure. Default is True. |
True
|
self_scaling
|
float
|
The scaling factor for self-dependence. Default is 1.0. |
1.0
|
with_bspline
|
bool
|
If True, enables B-spline expansion for data transformation. Default is False. |
False
|
with_taylor
|
bool
|
If True, enables Taylor expansion for data transformation. Default is False. |
False
|
d
|
int
|
The degree of Taylor or B-spline expansion. Default is 2. |
2
|
with_hybrid_expansion
|
bool
|
If True, enables hybrid data expansion. Default is False. |
False
|
with_dual_lphm
|
bool
|
If True, enables dual low-parametric hypermatrix reconciliation. Default is False. |
False
|
with_lorr
|
bool
|
If True, enables low-rank parameterized reconciliation. Default is False. |
False
|
r
|
int
|
The rank for low-rank parameterized reconciliation. Default is 3. |
3
|
with_residual
|
bool
|
If True, enables residual connections in the layers. Default is False. |
False
|
with_dual_lphm_interdependence
|
bool
|
If True, enables dual low-parametric hypermatrix interdependence. Default is False. |
False
|
with_lorr_interdependence
|
bool
|
If True, enables low-rank interdependence. Default is False. |
False
|
r_interdependence
|
int
|
The rank for low-rank interdependence. Default is 3. |
3
|
enable_bias
|
bool
|
If True, enables bias in the layers. Default is False. |
False
|
with_batch_norm
|
bool
|
If True, applies batch normalization to the layers. Default is False. |
False
|
with_relu
|
bool
|
If True, applies ReLU activation to the layers. Default is True. |
True
|
with_softmax
|
bool
|
If True, applies Softmax activation to the output layer. Default is True. |
True
|
with_dropout
|
bool
|
If True, applies dropout to the layers. Default is False. |
False
|
p
|
float
|
Dropout probability. Default is 0.25. |
0.25
|
parameters_init_method
|
str
|
The method for parameter initialization. Default is 'xavier_normal'. |
'xavier_normal'
|
device
|
str
|
The device to use for computation ('cpu' or 'cuda'). Default is 'cpu'. |
'cpu'
|
*args
|
optional
|
Additional positional arguments for the |
()
|
**kwargs
|
optional
|
Additional keyword arguments for the |
{}
|
Raises:
Type | Description |
---|---|
ValueError
|
If |
Methods:
Name | Description |
---|---|
__init__ |
Initializes the RNN model. |
forward |
Performs a forward pass through the RNN model. |
Source code in tinybig/model/rpn_regression_rnn.py
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 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 |
|
__init__(chain_length, dims, name='rpn_rnn', channel_num=1, width=1, bi_directional=False, with_multihop=False, h=1, accumulative=False, with_inverse_approx=False, with_exponential_approx=False, self_dependence=True, self_scaling=1.0, with_bspline=False, with_taylor=False, d=2, with_hybrid_expansion=False, with_dual_lphm=False, with_lorr=False, r=3, with_residual=False, with_dual_lphm_interdependence=False, with_lorr_interdependence=False, r_interdependence=3, enable_bias=False, with_batch_norm=False, with_relu=True, with_softmax=True, with_dropout=False, p=0.25, parameters_init_method='xavier_normal', device='cpu', *args, **kwargs)
Initialize the RNN model as a RPN.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
chain_length
|
int
|
The length of the chain structure for the RNN layers. |
required |
dims
|
list[int] | tuple[int]
|
A list or tuple of integers representing the dimensions of each layer. Must contain at least two dimensions. |
required |
name
|
str
|
The name of the RNN model. Default is 'rpn_rnn'. |
'rpn_rnn'
|
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
|
bi_directional
|
bool
|
If True, enables bidirectional processing in the chain structure. Default is False. |
False
|
with_multihop
|
bool
|
If True, enables multi-hop interdependence in the chain structure. Default is False. |
False
|
h
|
int
|
Number of hops for multi-hop interdependence. Default is 1. |
1
|
accumulative
|
bool
|
If True, accumulates multi-hop dependencies. Default is False. |
False
|
with_inverse_approx
|
bool
|
If True, enables inverse approximation for interdependence. Default is False. |
False
|
with_exponential_approx
|
bool
|
If True, enables exponential approximation for interdependence. Default is False. |
False
|
self_dependence
|
bool
|
If True, enables self-dependence in the chain structure. Default is True. |
True
|
self_scaling
|
float
|
Scaling factor for self-dependence. Default is 1.0. |
1.0
|
with_bspline
|
bool
|
If True, enables B-spline expansion for data transformation. Default is False. |
False
|
with_taylor
|
bool
|
If True, enables Taylor expansion for data transformation. Default is False. |
False
|
d
|
int
|
Degree of the expansion function (B-spline or Taylor). Default is 2. |
2
|
with_hybrid_expansion
|
bool
|
If True, enables hybrid data expansion. Default is False. |
False
|
with_dual_lphm
|
bool
|
If True, enables dual low-parametric hypermatrix 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
|
with_residual
|
bool
|
If True, adds residual connections to the layers. Default is False. |
False
|
with_dual_lphm_interdependence
|
bool
|
If True, enables dual low-parametric hypermatrix interdependence. Default is False. |
False
|
with_lorr_interdependence
|
bool
|
If True, enables low-rank interdependence. Default is False. |
False
|
r_interdependence
|
int
|
Rank for low-rank interdependence. Default is 3. |
3
|
enable_bias
|
bool
|
If True, enables bias in the layers. Default is False. |
False
|
with_batch_norm
|
bool
|
If True, applies batch normalization to the layers. Default is False. |
False
|
with_relu
|
bool
|
If True, applies ReLU activation to the layers. Default is True. |
True
|
with_softmax
|
bool
|
If True, applies Softmax activation to the output layer. Default is True. |
True
|
with_dropout
|
bool
|
If True, applies dropout to the layers. Default is False. |
False
|
p
|
float
|
Dropout probability. Default is 0.25. |
0.25
|
parameters_init_method
|
str
|
Initialization method for the parameters. Default is 'xavier_normal'. |
'xavier_normal'
|
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_regression_rnn.py
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 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 |
|
forward(x, device='cpu', *args, **kwargs)
Performs a forward pass through the RNN model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
Tensor
|
The input tensor of shape (batch_size, input_dim). |
required |
device
|
str
|
The device to use for computation ('cpu' or 'cuda'). Default is 'cpu'. |
'cpu'
|
*args
|
optional
|
Additional positional arguments. |
()
|
**kwargs
|
optional
|
Additional keyword arguments. |
{}
|
Returns:
Type | Description |
---|---|
Tensor
|
The output tensor after processing through the RNN model. |