参考: 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)
本文详细介绍使用PyTorch框架创建神经网络模型的过程。通过nn.Sequential模块,将多个神经网络层如Linear层和ReLU激活函数串联起来,形成一个多层神经网络。模型接收输入并生成预测输出,展示了神经网络的基本构建和工作原理。
2592

被折叠的 条评论
为什么被折叠?



