当前位置:网站首页>Pytorch MLP
Pytorch MLP
2022-07-05 11:43:00 【My abyss, my abyss】
1、 Hidden layer
Input layer and hidden layer are fully connected
The hidden layer and the output layer are fully connected
2、 Activation function
Activation function (activation function) Determine whether neurons should be activated by calculating the weighted sum and adding bias , They convert an input signal into a differentiable operation of an output .
3、 Summary
The multi-layer perceptron adds one or more fully connected hidden layers between the output layer and the input layer , And convert the output of the hidden layer through the activation function . So that the multi-layer perceptron can carry out nonlinear fitting .
Common activation functions include ReLU function 、sigmoid Functions and tanh function .
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)
边栏推荐
- SET XACT_ABORT ON
- 11.(地图数据篇)OSM数据如何下载使用
- redis的持久化机制原理
- MySQL 巨坑:update 更新慎用影响行数做判断!!!
- 【yolov5.yaml解析】
- 2048 game logic
- redis主从中的Master自动选举之Sentinel哨兵机制
- Go language learning notes - first acquaintance with go language
- CDGA|数据治理不得不坚持的六个原则
- COMSOL -- establishment of geometric model -- establishment of two-dimensional graphics
猜你喜欢
Redis集群(主从)脑裂及解决方案
iTOP-3568开发板NPU使用安装RKNN Toolkit Lite2
如何让你的产品越贵越好卖
【爬虫】charles unknown错误
11.(地图数据篇)OSM数据如何下载使用
无密码身份验证如何保障用户隐私安全?
Oneforall installation and use
12. (map data) cesium city building map
Harbor image warehouse construction
[singleshotmultiboxdetector (SSD, single step multi frame target detection)]
随机推荐
ZCMU--1390: 队列问题(1)
leetcode:1200. Minimum absolute difference
【yolov5.yaml解析】
MySQL 巨坑:update 更新慎用影响行数做判断!!!
紫光展锐全球首个5G R17 IoT NTN卫星物联网上星实测完成
【pytorch 修改预训练模型:实测加载预训练模型与模型随机初始化差别不大】
[crawler] bugs encountered by wasm
Startup process of uboot:
comsol--三维图形随便画----回转
Install esxi 6.0 interactively
Redis集群(主从)脑裂及解决方案
Question and answer 45: application of performance probe monitoring principle node JS probe
解决readObjectStart: expect { or n, but found N, error found in #1 byte of ...||..., bigger context ..
13. (map data) conversion between Baidu coordinate (bd09), national survey of China coordinate (Mars coordinate, gcj02), and WGS84 coordinate system
Manage multiple instagram accounts and share anti Association tips
redis 集群模式原理
【SingleShotMultiBoxDetector(SSD,单步多框目标检测)】
An error is reported in the process of using gbase 8C database: 80000305, host IPS long to different cluster. How to solve it?
redis主从模式
Prevent browser backward operation