输出结果为:

Net( (fc1): Linear(in_features=10, out_features=20, bias=True) (fc2): Linear(in_features=20, out_features=30, bias=True) (fc3): Linear(in_features=30, out_features=1, bias=True) )

说明该神经网络有三层,分别是输入层、隐藏层和输出层,输入层维度为10,隐藏层1维度为20,隐藏层2维度为30,输出层维度为1。每一层都是线性变换加上ReLU激活函数。

# 导入PyTorch模块import torchimport torchnn as nnimport torchnnfunctional as Fimport torchoptim as optim# 定义一个三层全连接神经网络类class NetnnModule def __init__self superNet self__init__

原文地址: https://www.cveoy.top/t/topic/dxdU 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录