当前位置:网站首页>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)
边栏推荐
- ACID事务理论
- Sklearn model sorting
- MySQL 巨坑:update 更新慎用影响行数做判断!!!
- redis的持久化机制原理
- How to make your products as expensive as possible
- Shell script file traversal STR to array string splicing
- 【L1、L2、smooth L1三类损失函数】
- Is it difficult to apply for a job after graduation? "Hundreds of days and tens of millions" online recruitment activities to solve your problems
- Question and answer 45: application of performance probe monitoring principle node JS probe
- 【load dataset】
猜你喜欢
13. (map data) conversion between Baidu coordinate (bd09), national survey of China coordinate (Mars coordinate, gcj02), and WGS84 coordinate system
How did the situation that NFT trading market mainly uses eth standard for trading come into being?
Pytorch training process was interrupted
pytorch训练进程被中断了
CDGA|数据治理不得不坚持的六个原则
Mongodb replica set
紫光展锐全球首个5G R17 IoT NTN卫星物联网上星实测完成
简单解决redis cluster中从节点读取不了数据(error) MOVED
[crawler] bugs encountered by wasm
【无标题】
随机推荐
[leetcode] wild card matching
中非 钻石副石怎么镶嵌,才能既安全又好看?
pytorch训练进程被中断了
Mysql统计技巧:ON DUPLICATE KEY UPDATE用法
NFT 交易市场主要使用 ETH 本位进行交易的局面是如何形成的?
Harbor镜像仓库搭建
Programmers are involved and maintain industry competitiveness
pytorch-多层感知机MLP
pytorch-线性回归
View all processes of multiple machines
yolov5目标检测神经网络——损失函数计算原理
SET XACT_ ABORT ON
12.(地图数据篇)cesium城市建筑物贴图
1.php的laravel创建项目
Sklearn model sorting
Manage multiple instagram accounts and share anti Association tips
871. Minimum Number of Refueling Stops
Acid transaction theory
POJ 3176-Cow Bowling(DP||记忆化搜索)
2048 game logic