当前位置:网站首页>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)

边栏推荐
- What does cross-border e-commerce mean? What do you mainly do? What are the business models?
- 紫光展锐全球首个5G R17 IoT NTN卫星物联网上星实测完成
- Implementation of array hash function in PHP
- 7 themes and 9 technology masters! Dragon Dragon lecture hall hard core live broadcast preview in July, see you tomorrow
- ACID事务理论
- 中非 钻石副石怎么镶嵌,才能既安全又好看?
- 简单解决redis cluster中从节点读取不了数据(error) MOVED
- 【SingleShotMultiBoxDetector(SSD,单步多框目标检测)】
- Technology sharing | common interface protocol analysis
- Zcmu--1390: queue problem (1)
猜你喜欢

【TFLite, ONNX, CoreML, TensorRT Export】

COMSOL--三维图形的建立

Is it difficult to apply for a job after graduation? "Hundreds of days and tens of millions" online recruitment activities to solve your problems

CDGA|数据治理不得不坚持的六个原则

redis主从模式

redis 集群模式原理

yolov5目標檢測神經網絡——損失函數計算原理

谜语1

【L1、L2、smooth L1三类损失函数】

11. (map data section) how to download and use OSM data
随机推荐
[yolov3 loss function]
查看多台机器所有进程
2048 game logic
Ziguang zhanrui's first 5g R17 IOT NTN satellite in the world has been measured on the Internet of things
pytorch-权重衰退(weight decay)和丢弃法(dropout)
Programmers are involved and maintain industry competitiveness
c#操作xml文件
Zcmu--1390: queue problem (1)
Pytorch training process was interrupted
一次生产环境redis内存占用居高不下问题排查
Mongodb replica set
Shell script file traversal STR to array string splicing
vscode快捷键
Harbor image warehouse construction
redis 集群模式原理
COMSOL -- three-dimensional graphics random drawing -- rotation
C operation XML file
How to get a token from tokenstream based on Lucene 3.5.0
《增长黑客》阅读笔记
How to understand super browser? What scenarios can it be used in? What brands are there?