当前位置:网站首页>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)
边栏推荐
- Open3D 网格(曲面)赋色
- [there may be no default font]warning: imagettfbbox() [function.imagettfbbox]: invalid font filename
- Lombok makes ⽤ @data and @builder's pit at the same time. Are you hit?
- 11. (map data section) how to download and use OSM data
- 简单解决redis cluster中从节点读取不了数据(error) MOVED
- ibatis的动态sql
- Redis集群的重定向
- 我用开天平台做了一个城市防疫政策查询系统【开天aPaaS大作战】
- OneForAll安装使用
- View all processes of multiple machines
猜你喜欢
技术管理进阶——什么是管理者之体力、脑力、心力
Differences between IPv6 and IPv4 three departments including the office of network information technology promote IPv6 scale deployment
【无标题】
[crawler] bugs encountered by wasm
Evolution of multi-objective sorting model for classified tab commodity flow
简单解决redis cluster中从节点读取不了数据(error) MOVED
COMSOL--三维图形的建立
[office] eight usages of if function in Excel
11.(地图数据篇)OSM数据如何下载使用
如何让你的产品越贵越好卖
随机推荐
跨境电商是啥意思?主要是做什么的?业务模式有哪些?
Oneforall installation and use
无密码身份验证如何保障用户隐私安全?
What about SSL certificate errors? Solutions to common SSL certificate errors in browsers
XML parsing
Pytorch training process was interrupted
【爬虫】charles unknown错误
Summary of thread and thread synchronization under window
Solve readobjectstart: expect {or N, but found n, error found in 1 byte of
Summary of websites of app stores / APP markets
阻止瀏覽器後退操作
redis集群中hash tag 使用
FFmpeg调用avformat_open_input时返回错误 -22(Invalid argument)
Acid transaction theory
Harbor镜像仓库搭建
COMSOL--三维随便画--扫掠
Solve the problem of slow access to foreign public static resources
go语言学习笔记-初识Go语言
What does cross-border e-commerce mean? What do you mainly do? What are the business models?
ACID事务理论