当前位置:网站首页>pytorch-多层感知机MLP
pytorch-多层感知机MLP
2022-07-05 11:34:00 【我渊啊我渊啊】
1、隐藏层
输入层和隐藏层是全连接
隐藏层和输出层是全连接

2、激活函数
激活函数(activation function)通过计算加权和并加上偏置来确定神经元是否应该被激活, 它们将输入信号转换为输出的可微运算。
3、小结
多层感知机在输出层和输入层之间增加一个或多个全连接隐藏层,并通过激活函数转换隐藏层的输出。使得多层感知机可以进行非线性的拟合。
常用的激活函数包括ReLU函数、sigmoid函数和tanh函数。
import torch
from torch import nn
from d2l import torch as d2l
net = nn.Sequential(nn.Flatten(),
nn.Linear(784, 256),
nn.ReLU(),
nn.Linear(256, 10))
def init_weights(m):
if type(m) == nn.Linear:
nn.init.normal_(m.weight, std=0.01)
net.apply(init_weights);
batch_size, lr, num_epochs = 256, 0.1, 10
loss = nn.CrossEntropyLoss(reduction='none')
trainer = torch.optim.SGD(net.parameters(), lr=lr)
train_iter, test_iter = d2l.load_data_fashion_mnist(batch_size)
d2l.train_ch3(net, train_iter, test_iter, loss, num_epochs, trainer)

边栏推荐
- Guys, I tested three threads to write to three MySQL tables at the same time. Each thread writes 100000 pieces of data respectively, using F
- 一次生产环境redis内存占用居高不下问题排查
- Prevent browser backward operation
- 解决访问国外公共静态资源速度慢的问题
- Ziguang zhanrui's first 5g R17 IOT NTN satellite in the world has been measured on the Internet of things
- 我用开天平台做了一个城市防疫政策查询系统【开天aPaaS大作战】
- C # to obtain the filtered or sorted data of the GridView table in devaexpress
- 13.(地图数据篇)百度坐标(BD09)、国测局坐标(火星坐标,GCJ02)、和WGS84坐标系之间的转换
- c#操作xml文件
- 石油化工企业安全生产智能化管控系统平台建设思考和建议
猜你喜欢

【无标题】

11.(地图数据篇)OSM数据如何下载使用

Modulenotfounderror: no module named 'scratch' ultimate solution

一次生产环境redis内存占用居高不下问题排查

How did the situation that NFT trading market mainly uses eth standard for trading come into being?

紫光展锐全球首个5G R17 IoT NTN卫星物联网上星实测完成

Advanced technology management - what is the physical, mental and mental strength of managers
![[Oracle] use DataGrid to connect to Oracle Database](/img/4f/886378667889f730eaed39b97f0a39.png)
[Oracle] use DataGrid to connect to Oracle Database

pytorch训练进程被中断了

Is it difficult to apply for a job after graduation? "Hundreds of days and tens of millions" online recruitment activities to solve your problems
随机推荐
Three paradigms of database
边缘计算如何与物联网结合在一起?
C language current savings account management system
MFC pet store information management system
Cdga | six principles that data governance has to adhere to
Zcmu--1390: queue problem (1)
Redis如何实现多可用区?
In the last process before the use of the risk control model, 80% of children's shoes are trampled here
13. (map data) conversion between Baidu coordinate (bd09), national survey of China coordinate (Mars coordinate, gcj02), and WGS84 coordinate system
Advanced technology management - what is the physical, mental and mental strength of managers
[LeetCode] Wildcard Matching 外卡匹配
汉诺塔问题思路的证明
SET XACT_ABORT ON
高校毕业求职难?“百日千万”网络招聘活动解决你的难题
Unity xlua monoproxy mono proxy class
使用GBase 8c数据库过程中报错:80000305,Host ips belong to different cluster ,怎么解决?
Pytorch training process was interrupted
无密码身份验证如何保障用户隐私安全?
What about SSL certificate errors? Solutions to common SSL certificate errors in browsers
Unity Xlua MonoProxy Mono代理类