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

边栏推荐
- 13.(地图数据篇)百度坐标(BD09)、国测局坐标(火星坐标,GCJ02)、和WGS84坐标系之间的转换
- shell脚本文件遍历 str转数组 字符串拼接
- 871. Minimum Number of Refueling Stops
- Shell script file traversal STR to array string splicing
- Implementation of array hash function in PHP
- CDGA|数据治理不得不坚持的六个原则
- Prevent browser backward operation
- pytorch训练进程被中断了
- The ninth Operation Committee meeting of dragon lizard community was successfully held
- Mysql统计技巧:ON DUPLICATE KEY UPDATE用法
猜你喜欢

COMSOL--建立几何模型---二维图形的建立

COMSOL -- 3D casual painting -- sweeping

The ninth Operation Committee meeting of dragon lizard community was successfully held

Oneforall installation and use

Redis集群(主从)脑裂及解决方案

【爬虫】charles unknown错误

技术管理进阶——什么是管理者之体力、脑力、心力

13.(地图数据篇)百度坐标(BD09)、国测局坐标(火星坐标,GCJ02)、和WGS84坐标系之间的转换

XML parsing

comsol--三维图形随便画----回转
随机推荐
Solve the grpc connection problem. Dial succeeds with transientfailure
MySQL giant pit: update updates should be judged with caution by affecting the number of rows!!!
2048 game logic
C language current savings account management system
uboot的启动流程:
Solve the problem of slow access to foreign public static resources
龙蜥社区第九次运营委员会会议顺利召开
[SWT component] content scrolledcomposite
我用开天平台做了一个城市防疫政策查询系统【开天aPaaS大作战】
What about SSL certificate errors? Solutions to common SSL certificate errors in browsers
[there may be no default font]warning: imagettfbbox() [function.imagettfbbox]: invalid font filename
ibatis的动态sql
【无标题】
Redis集群的重定向
项目总结笔记系列 wsTax KT Session2 代码分析
Spark Tuning (I): from HQL to code
Basics - rest style development
XML解析
[crawler] Charles unknown error
Crawler (9) - scrape framework (1) | scrape asynchronous web crawler framework