pytorch: 将一序列操作串联

参考: https://pytorch.org/tutorials/beginner/pytorch_with_examples.html#id23

# Use the nn package to define our model as a sequence of layers.
# nn.Sequential is a model which contains other Modules,and applies them in sequence to
# produce its output.Each linear Module compute output from input using a
# linear function and holds internal Tensors for its weight and bias

model = torch.nn.Sequential(
    torch.nn.Linear(D_in,H),
    torch.nn.ReLU(),
    torch.nn.Linear(H,D_out)
)
y_pred = model(x)

 

猜你喜欢

转载自blog.csdn.net/Strive_For_Future/article/details/83185831