Skip to content

Commit

Permalink
【PPSCI Doc No.20】ppsci.arch.DeepPhyLSTM (PaddlePaddle#756)
Browse files Browse the repository at this point in the history
* [Add] phylstm examples

* [Change] phylstm examples

* [Change] remove blank line
  • Loading branch information
megemini authored Jan 17, 2024
1 parent 0fa9a14 commit 6cf2951
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion ppsci/arch/phylstm.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,46 @@ class DeepPhyLSTM(base.Arch):
model_type (int, optional): The model type, value is 2 or 3, 2 indicates having two sub-models, 3 indicates having three submodels. Defaults to 2.
Examples:
>>> import paddle
>>> import ppsci
>>> model = ppsci.arch.DeepPhyLSTM(1, 1, 100)
>>> # model_type is `2`
>>> model = ppsci.arch.DeepPhyLSTM(
... input_size=16,
... output_size=1,
... hidden_size=100,
... model_type=2)
>>> out = model(
... {"ag":paddle.rand([64, 16, 16]),
... "ag_c":paddle.rand([64, 16, 16]),
... "phi":paddle.rand([1, 16, 16])})
>>> for k, v in out.items():
... print(f"{k} {v.dtype} {v.shape}")
eta_pred paddle.float32 [64, 16, 1]
eta_dot_pred paddle.float32 [64, 16, 1]
g_pred paddle.float32 [64, 16, 1]
eta_t_pred_c paddle.float32 [64, 16, 1]
eta_dot_pred_c paddle.float32 [64, 16, 1]
lift_pred_c paddle.float32 [64, 16, 1]
>>> # model_type is `3`
>>> model = ppsci.arch.DeepPhyLSTM(
... input_size=16,
... output_size=1,
... hidden_size=100,
... model_type=3)
>>> out = model(
... {"ag":paddle.rand([64, 16, 1]),
... "ag_c":paddle.rand([64, 16, 1]),
... "phi":paddle.rand([1, 16, 16])})
>>> for k, v in out.items():
... print(f"{k} {v.dtype} {v.shape}")
eta_pred paddle.float32 [64, 16, 1]
eta_dot_pred paddle.float32 [64, 16, 1]
g_pred paddle.float32 [64, 16, 1]
eta_t_pred_c paddle.float32 [64, 16, 1]
eta_dot_pred_c paddle.float32 [64, 16, 1]
lift_pred_c paddle.float32 [64, 16, 1]
g_t_pred_c paddle.float32 [64, 16, 1]
g_dot_pred_c paddle.float32 [64, 16, 1]
"""

def __init__(self, input_size, output_size, hidden_size=100, model_type=2):
Expand Down

0 comments on commit 6cf2951

Please sign in to comment.