Arch(网络模型) 模块¶
ppsci.arch
¶
Arch
¶
Bases: Layer
Base class for Network.
Source code in ppsci/arch/base.py
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 |
|
num_params: int
property
¶
Return number of parameters within network.
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
Number of parameters. |
concat_to_tensor(data_dict, keys, axis=-1)
¶
Concatenate tensors from dict in the order of given keys.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_dict |
Dict[str, Tensor]
|
Dict contains tensor. |
required |
keys |
Tuple[str, ...]
|
Keys tensor fetched from. |
required |
axis |
int
|
Axis concatenate at. Defaults to -1. |
-1
|
Returns:
Type | Description |
---|---|
Tuple[Tensor, ...]
|
Tuple[paddle.Tensor, ...]: Concatenated tensor. |
Source code in ppsci/arch/base.py
register_input_transform(transform)
¶
Register input transform.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
transform |
Callable[[Dict[str, Tensor]], Dict[str, Tensor]]
|
Input transform of network, receive a single tensor dict and return a single tensor dict. |
required |
Source code in ppsci/arch/base.py
register_output_transform(transform)
¶
Register output transform.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
transform |
Callable[[Dict[str, Tensor], Dict[str, Tensor]], Dict[str, Tensor]]
|
Output transform of network, receive two single tensor dict(raw input and raw output) and return a single tensor dict(transformed output). |
required |
Source code in ppsci/arch/base.py
split_to_dict(data_tensor, keys, axis=-1)
¶
Split tensor and wrap into a dict by given keys.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_tensor |
Tensor
|
Tensor to be split. |
required |
keys |
Tuple[str, ...]
|
Keys tensor mapping to. |
required |
axis |
int
|
Axis split at. Defaults to -1. |
-1
|
Returns:
Type | Description |
---|---|
Dict[str, Tensor]
|
Dict[str, paddle.Tensor]: Dict contains tensor. |
Source code in ppsci/arch/base.py
AMGNet
¶
Bases: Layer
A Multi-scale Graph neural Network model based on Encoder-Process-Decoder structure for flow field prediction.
https://doi.org/10.1080/09540091.2022.2131737
Code reference: https://github.com/baoshiaijhin/amgnet
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_keys |
Tuple[str, ...]
|
Name of input keys, such as ("input", ). |
required |
output_keys |
Tuple[str, ...]
|
Name of output keys, such as ("pred", ). |
required |
input_dim |
int
|
Number of input dimension. |
required |
output_dim |
int
|
Number of output dimension. |
required |
latent_dim |
int
|
Number of hidden(feature) dimension. |
required |
num_layers |
int
|
Number of layer(s). |
required |
message_passing_aggregator |
Literal['sum']
|
Message aggregator method in graph. Only "sum" available now. |
required |
message_passing_steps |
int
|
Message passing steps in graph. |
required |
speed |
str
|
Whether use vanilla method or fast method for graph_connectivity computation. |
required |
Examples:
Source code in ppsci/arch/amgnet.py
559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 |
|
MLP
¶
Bases: Arch
Multi layer perceptron network.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_keys |
Tuple[str, ...]
|
Name of input keys, such as ("x", "y", "z"). |
required |
output_keys |
Tuple[str, ...]
|
Name of output keys, such as ("u", "v", "w"). |
required |
num_layers |
int
|
Number of hidden layers. |
required |
hidden_size |
Union[int, Tuple[int, ...]]
|
Number of hidden size. An integer for all layers, or list of integer specify each layer's size. |
required |
activation |
str
|
Name of activation function. Defaults to "tanh". |
'tanh'
|
skip_connection |
bool
|
Whether to use skip connection. Defaults to False. |
False
|
weight_norm |
bool
|
Whether to apply weight norm on parameter(s). Defaults to False. |
False
|
input_dim |
Optional[int]
|
Number of input's dimension. Defaults to None. |
None
|
output_dim |
Optional[int]
|
Number of output's dimension. Defaults to None. |
None
|
Examples:
Source code in ppsci/arch/mlp.py
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 |
|
DeepONet
¶
Bases: Arch
Deep operator network.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
u_key |
str
|
Name of function data for input function u(x). |
required |
y_key |
str
|
Name of location data for input function G(u). |
required |
G_key |
str
|
Output name of predicted G(u)(y). |
required |
num_loc |
int
|
Number of sampled u(x), i.e. |
required |
num_features |
int
|
Number of features extracted from u(x), same for y. |
required |
branch_num_layers |
int
|
Number of hidden layers of branch net. |
required |
trunk_num_layers |
int
|
Number of hidden layers of trunk net. |
required |
branch_hidden_size |
Union[int, Tuple[int, ...]]
|
Number of hidden size of branch net. An integer for all layers, or list of integer specify each layer's size. |
required |
trunk_hidden_size |
Union[int, Tuple[int, ...]]
|
Number of hidden size of trunk net. An integer for all layers, or list of integer specify each layer's size. |
required |
branch_skip_connection |
bool
|
Whether to use skip connection for branch net. Defaults to False. |
False
|
trunk_skip_connection |
bool
|
Whether to use skip connection for trunk net. Defaults to False. |
False
|
branch_activation |
str
|
Name of activation function. Defaults to "tanh". |
'tanh'
|
trunk_activation |
str
|
Name of activation function. Defaults to "tanh". |
'tanh'
|
branch_weight_norm |
bool
|
Whether to apply weight norm on parameter(s) for branch net. Defaults to False. |
False
|
trunk_weight_norm |
bool
|
Whether to apply weight norm on parameter(s) for trunk net. Defaults to False. |
False
|
use_bias |
bool
|
Whether to add bias on predicted G(u)(y). Defaults to True. |
True
|
Examples:
>>> import ppsci
>>> model = ppsci.arch.DeepONet(
... "u", "y", "G",
... 100, 40,
... 1, 1,
... 40, 40,
... branch_activation="relu", trunk_activation="relu",
... use_bias=True,
... )
Source code in ppsci/arch/deeponet.py
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 |
|
DeepPhyLSTM
¶
Bases: Arch
DeepPhyLSTM init function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_size |
int
|
The input size. |
required |
output_size |
int
|
The output size. |
required |
hidden_size |
int
|
The hidden size. Defaults to 100. |
100
|
model_type |
int
|
The model type, value is 2 or 3, 2 indicates having two sub-models, 3 indicates having three submodels. Defaults to 2. |
2
|
Examples:
Source code in ppsci/arch/phylstm.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 |
|
LorenzEmbedding
¶
Bases: Arch
Embedding Koopman model for the Lorenz ODE system.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_keys |
Tuple[str, ...]
|
Input keys, such as ("states",). |
required |
output_keys |
Tuple[str, ...]
|
Output keys, such as ("pred_states", "recover_states"). |
required |
mean |
Optional[Tuple[float, ...]]
|
Mean of training dataset. Defaults to None. |
None
|
std |
Optional[Tuple[float, ...]]
|
Standard Deviation of training dataset. Defaults to None. |
None
|
input_size |
int
|
Size of input data. Defaults to 3. |
3
|
hidden_size |
int
|
Number of hidden size. Defaults to 500. |
500
|
embed_size |
int
|
Number of embedding size. Defaults to 32. |
32
|
drop |
float
|
Probability of dropout the units. Defaults to 0.0. |
0.0
|
Examples:
Source code in ppsci/arch/embedding_koopman.py
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 |
|
RosslerEmbedding
¶
Bases: LorenzEmbedding
Embedding Koopman model for the Rossler ODE system.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_keys |
Tuple[str, ...]
|
Input keys, such as ("states",). |
required |
output_keys |
Tuple[str, ...]
|
Output keys, such as ("pred_states", "recover_states"). |
required |
mean |
Optional[Tuple[float, ...]]
|
Mean of training dataset. Defaults to None. |
None
|
std |
Optional[Tuple[float, ...]]
|
Standard Deviation of training dataset. Defaults to None. |
None
|
input_size |
int
|
Size of input data. Defaults to 3. |
3
|
hidden_size |
int
|
Number of hidden size. Defaults to 500. |
500
|
embed_size |
int
|
Number of embedding size. Defaults to 32. |
32
|
drop |
float
|
Probability of dropout the units. Defaults to 0.0. |
0.0
|
Examples:
Source code in ppsci/arch/embedding_koopman.py
CylinderEmbedding
¶
Bases: Arch
Embedding Koopman model for the Cylinder system.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_keys |
Tuple[str, ...]
|
Input keys, such as ("states", "visc"). |
required |
output_keys |
Tuple[str, ...]
|
Output keys, such as ("pred_states", "recover_states"). |
required |
mean |
Optional[Tuple[float, ...]]
|
Mean of training dataset. Defaults to None. |
None
|
std |
Optional[Tuple[float, ...]]
|
Standard Deviation of training dataset. Defaults to None. |
None
|
embed_size |
int
|
Number of embedding size. Defaults to 128. |
128
|
encoder_channels |
Optional[Tuple[int, ...]]
|
Number of channels in encoder network. Defaults to None. |
None
|
decoder_channels |
Optional[Tuple[int, ...]]
|
Number of channels in decoder network. Defaults to None. |
None
|
drop |
float
|
Probability of dropout the units. Defaults to 0.0. |
0.0
|
Examples:
Source code in ppsci/arch/embedding_koopman.py
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 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 |
|
Generator
¶
Bases: Arch
Generator Net of GAN. Attention, the net using a kind of variant of ResBlock which is unique to "tempoGAN" example but not an open source network.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_keys |
Tuple[str, ...]
|
Name of input keys, such as ("input1", "input2"). |
required |
output_keys |
Tuple[str, ...]
|
Name of output keys, such as ("output1", "output2"). |
required |
in_channel |
int
|
Number of input channels of the first conv layer. |
required |
out_channels_tuple |
Tuple[Tuple[int, ...], ...]
|
Number of output channels of all conv layers, such as [[out_res0_conv0, out_res0_conv1], [out_res1_conv0, out_res1_conv1]] |
required |
kernel_sizes_tuple |
Tuple[Tuple[int, ...], ...]
|
Number of kernel_size of all conv layers, such as [[kernel_size_res0_conv0, kernel_size_res0_conv1], [kernel_size_res1_conv0, kernel_size_res1_conv1]] |
required |
strides_tuple |
Tuple[Tuple[int, ...], ...]
|
Number of stride of all conv layers, such as [[stride_res0_conv0, stride_res0_conv1], [stride_res1_conv0, stride_res1_conv1]] |
required |
use_bns_tuple |
Tuple[Tuple[bool, ...], ...]
|
Whether to use the batch_norm layer after each conv layer. |
required |
acts_tuple |
Tuple[Tuple[str, ...], ...]
|
Whether to use the activation layer after each conv layer. If so, witch activation to use, such as [[act_res0_conv0, act_res0_conv1], [act_res1_conv0, act_res1_conv1]] |
required |
Examples:
>>> import ppsci
>>> in_channel = 1
>>> rb_channel0 = (2, 8, 8)
>>> rb_channel1 = (128, 128, 128)
>>> rb_channel2 = (32, 8, 8)
>>> rb_channel3 = (2, 1, 1)
>>> out_channels_tuple = (rb_channel0, rb_channel1, rb_channel2, rb_channel3)
>>> kernel_sizes_tuple = (((5, 5), ) * 2 + ((1, 1), ), ) * 4
>>> strides_tuple = ((1, 1, 1), ) * 4
>>> use_bns_tuple = ((True, True, True), ) * 3 + ((False, False, False), )
>>> acts_tuple = (("relu", None, None), ) * 4
>>> model = ppsci.arch.Generator(("in",), ("out",), in_channel, out_channels_tuple, kernel_sizes_tuple, strides_tuple, use_bns_tuple, acts_tuple)
Source code in ppsci/arch/gan.py
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 |
|
Discriminator
¶
Bases: Arch
Discriminator Net of GAN.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_keys |
Tuple[str, ...]
|
Name of input keys, such as ("input1", "input2"). |
required |
output_keys |
Tuple[str, ...]
|
Name of output keys, such as ("output1", "output2"). |
required |
in_channel |
int
|
Number of input channels of the first conv layer. |
required |
out_channels |
Tuple[int, ...]
|
Number of output channels of all conv layers, such as (out_conv0, out_conv1, out_conv2). |
required |
fc_channel |
int
|
Number of input features of linear layer. Number of output features of the layer is set to 1 in this Net to construct a fully_connected layer. |
required |
kernel_sizes |
Tuple[int, ...]
|
Number of kernel_size of all conv layers, such as (kernel_size_conv0, kernel_size_conv1, kernel_size_conv2). |
required |
strides |
Tuple[int, ...]
|
Number of stride of all conv layers, such as (stride_conv0, stride_conv1, stride_conv2). |
required |
use_bns |
Tuple[bool, ...]
|
Whether to use the batch_norm layer after each conv layer. |
required |
acts |
Tuple[str, ...]
|
Whether to use the activation layer after each conv layer. If so, witch activation to use, such as (act_conv0, act_conv1, act_conv2). |
required |
Examples:
>>> import ppsci
>>> in_channel = 2
>>> in_channel_tempo = 3
>>> out_channels = (32, 64, 128, 256)
>>> fc_channel = 65536
>>> kernel_sizes = ((4, 4), (4, 4), (4, 4), (4, 4))
>>> strides = (2, 2, 2, 1)
>>> use_bns = (False, True, True, True)
>>> acts = ("leaky_relu", "leaky_relu", "leaky_relu", "leaky_relu", None)
>>> output_keys_disc = ("out_1", "out_2", "out_3", "out_4", "out_5", "out_6", "out_7", "out_8", "out_9", "out_10")
>>> model = ppsci.arch.Discriminator(("in_1","in_2"), output_keys_disc, in_channel, out_channels, fc_channel, kernel_sizes, strides, use_bns, acts)
Source code in ppsci/arch/gan.py
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 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 |
|
split_to_dict(data_list, keys)
¶
Overwrite of split_to_dict() method belongs to Class base.Arch.
Reason for overwriting is there is no concat_to_tensor() method called in "tempoGAN" example. That is because input in "tempoGAN" example is not in a regular format, but a format like: { "input1": paddle.concat([in1, in2], axis=1), "input2": paddle.concat([in1, in3], axis=1), }
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_list |
List[Tensor]
|
The data to be split. It should be a list of tensor(s), but not a paddle.Tensor. |
required |
keys |
Tuple[str, ...]
|
Keys of outputs. |
required |
Returns:
Type | Description |
---|---|
Dict[str, Tensor]
|
Dict[str, paddle.Tensor]: Dict with split data. |
Source code in ppsci/arch/gan.py
PhysformerGPT2
¶
Bases: Arch
Transformer decoder model for modeling physics.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_keys |
Tuple[str, ...]
|
Input keys, such as ("embeds",). |
required |
output_keys |
Tuple[str, ...]
|
Output keys, such as ("pred_embeds",). |
required |
num_layers |
int
|
Number of transformer layers. |
required |
num_ctx |
int
|
Context length of block. |
required |
embed_size |
int
|
The number of embedding size. |
required |
num_heads |
int
|
The number of heads in multi-head attention. |
required |
embd_pdrop |
float
|
The dropout probability used on embedding features. Defaults to 0.0. |
0.0
|
attn_pdrop |
float
|
The dropout probability used on attention weights. Defaults to 0.0. |
0.0
|
resid_pdrop |
float
|
The dropout probability used on block outputs. Defaults to 0.0. |
0.0
|
initializer_range |
float
|
Initializer range of linear layer. Defaults to 0.05. |
0.05
|
Examples:
>>> import ppsci
>>> model = ppsci.arch.PhysformerGPT2(("embeds", ), ("pred_embeds", ), 6, 16, 128, 4)
Source code in ppsci/arch/physx_transformer.py
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 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 |
|
ModelList
¶
Bases: Arch
ModelList layer which wrap more than one model that shares inputs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_list |
Tuple[Arch, ...]
|
Model(s) nested in tuple. |
required |
Examples:
>>> import ppsci
>>> model1 = ppsci.arch.MLP(("x", "y"), ("u", "v"), 10, 128)
>>> model2 = ppsci.arch.MLP(("x", "y"), ("w", "p"), 5, 128)
>>> model = ppsci.arch.ModelList((model1, model2))
Source code in ppsci/arch/model_list.py
AFNONet
¶
Bases: Arch
Adaptive Fourier Neural Network.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_keys |
Tuple[str, ...]
|
Name of input keys, such as ("input",). |
required |
output_keys |
Tuple[str, ...]
|
Name of output keys, such as ("output",). |
required |
img_size |
Tuple[int, ...]
|
Image size. Defaults to (720, 1440). |
(720, 1440)
|
patch_size |
Tuple[int, ...]
|
Path. Defaults to (8, 8). |
(8, 8)
|
in_channels |
int
|
The input tensor channels. Defaults to 20. |
20
|
out_channels |
int
|
The output tensor channels. Defaults to 20. |
20
|
embed_dim |
int
|
The embedding dimension for PatchEmbed. Defaults to 768. |
768
|
depth |
int
|
Number of transformer depth. Defaults to 12. |
12
|
mlp_ratio |
float
|
Number of ratio used in MLP. Defaults to 4.0. |
4.0
|
drop_rate |
float
|
The drop ratio used in MLP. Defaults to 0.0. |
0.0
|
drop_path_rate |
float
|
The drop ratio used in DropPath. Defaults to 0.0. |
0.0
|
num_blocks |
int
|
Number of blocks. Defaults to 8. |
8
|
sparsity_threshold |
float
|
The value of threshold for softshrink. Defaults to 0.01. |
0.01
|
hard_thresholding_fraction |
float
|
The value of threshold for keep mode. Defaults to 1.0. |
1.0
|
num_timestamps |
int
|
Number of timestamp. Defaults to 1. |
1
|
Examples:
Source code in ppsci/arch/afno.py
394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 |
|
PrecipNet
¶
Bases: Arch
Precipitation Network.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_keys |
Tuple[str, ...]
|
Name of input keys, such as ("input",). |
required |
output_keys |
Tuple[str, ...]
|
Name of output keys, such as ("output",). |
required |
wind_model |
Arch
|
Wind model. |
required |
img_size |
Tuple[int, ...]
|
Image size. Defaults to (720, 1440). |
(720, 1440)
|
patch_size |
Tuple[int, ...]
|
Path. Defaults to (8, 8). |
(8, 8)
|
in_channels |
int
|
The input tensor channels. Defaults to 20. |
20
|
out_channels |
int
|
The output tensor channels. Defaults to 1. |
1
|
embed_dim |
int
|
The embedding dimension for PatchEmbed. Defaults to 768. |
768
|
depth |
int
|
Number of transformer depth. Defaults to 12. |
12
|
mlp_ratio |
float
|
Number of ratio used in MLP. Defaults to 4.0. |
4.0
|
drop_rate |
float
|
The drop ratio used in MLP. Defaults to 0.0. |
0.0
|
drop_path_rate |
float
|
The drop ratio used in DropPath. Defaults to 0.0. |
0.0
|
num_blocks |
int
|
Number of blocks. Defaults to 8. |
8
|
sparsity_threshold |
float
|
The value of threshold for softshrink. Defaults to 0.01. |
0.01
|
hard_thresholding_fraction |
float
|
The value of threshold for keep mode. Defaults to 1.0. |
1.0
|
num_timestamps |
int
|
Number of timestamp. Defaults to 1. |
1
|
Examples:
>>> import ppsci
>>> wind_model = ppsci.arch.AFNONet(("input", ), ("output", ))
>>> model = ppsci.arch.PrecipNet(("input", ), ("output", ), wind_model)
Source code in ppsci/arch/afno.py
556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 |
|
UNetEx
¶
Bases: Arch
U-Net
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_key |
str
|
Name of function data for input. |
required |
output_key |
str
|
Name of function data for output. |
required |
in_channel |
int
|
Number of channels of input. |
required |
out_channel |
int
|
Number of channels of output. |
required |
kernel_size |
int
|
Size of kernel of convolution layer. Defaults to 3. |
3
|
filters |
Tuple[int, ...]
|
Number of filters. Defaults to (16, 32, 64). |
(16, 32, 64)
|
layers |
int
|
Number of encoders or decoders. Defaults to 3. |
3
|
weight_norm |
bool
|
Whether use weight normalization layer. Defaults to True. |
True
|
batch_norm |
bool
|
Whether add batch normalization layer. Defaults to True. |
True
|
activation |
Type[Layer]
|
Name of activation function. Defaults to nn.ReLU. |
ReLU
|
final_activation |
Optional[Type[Layer]]
|
Name of final activation function. Defaults to None. |
None
|
Examples:
>>> import ppsci
>>> model = ppsci.arch.ppsci.arch.UNetEx("input", "output", 3, 3, (8, 16, 32, 32), 5, False, False)
Source code in ppsci/arch/unetex.py
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 |
|
NowcastNet
¶
Bases: Arch
The NowcastNet model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_keys |
Tuple[str, ...]
|
Name of input keys, such as ("input",). |
required |
output_keys |
Tuple[str, ...]
|
Name of output keys, such as ("output",). |
required |
input_length |
int
|
Input length. Defaults to 9. |
9
|
total_length |
int
|
Total length. Defaults to 29. |
29
|
image_height |
int
|
Image height. Defaults to 512. |
512
|
image_width |
int
|
Image width. Defaults to 512. |
512
|
image_ch |
int
|
Image channel. Defaults to 2. |
2
|
ngf |
int
|
Noise Projector input length. Defaults to 32. |
32
|
Examples:
Source code in ppsci/arch/nowcastnet.py
9 10 11 12 13 14 15 16 17 18 19 20 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 |
|
创建日期: November 6, 2023