mindflow.pde.Poisson
- class mindflow.pde.Poisson(model, loss_fn='mse')[源代码]
基于PDEWithLoss定义的二维泊松方程求解问题。
- 参数:
model (mindspore.nn.Cell) - 用于训练的网络模型。
loss_fn (Union[str, Cell]) - 损失函数。默认值:
"mse"
。
- 支持平台:
Ascend
GPU
样例:
>>> from mindflow.pde import Poisson >>> from mindspore import nn, ops >>> class Net(nn.Cell): ... def __init__(self, cin=2, cout=1, hidden=10): ... super().__init__() ... self.fc1 = nn.Dense(cin, hidden) ... self.fc2 = nn.Dense(hidden, hidden) ... self.fcout = nn.Dense(hidden, cout) ... self.act = ops.Tanh() ... ... def construct(self, x): ... x = self.act(self.fc1(x)) ... x = self.act(self.fc2(x)) ... x = self.fcout(x) ... return x >>> model = Net() >>> problem = Poisson(model) >>> print(problem.pde()) poisson: Derivative(u(x, y), (x, 2)) + Derivative(u(x, y), (y, 2)) + 1.0 Item numbers of current derivative formula nodes: 3 {'poisson': Derivative(u(x, y), (x, 2)) + Derivative(u(x, y), (y, 2)) + 1.0}