当前位置:网站首页>《动手学深度学习》学习笔记
《动手学深度学习》学习笔记
2022-07-05 04:58:00 【fb_help】
《动手学深度学习》学习笔记
数据操作

自动求导
变量设置求导
x = torch.ones(2, 2, requires_grad=True)
获得导数
out.backward()
这里要求因变量为标量,如果为tensor,则需要提供一个与因变量同大小的权重矩阵,通过加权求和所有元素来把输出的因变量变成标量,然后才能backward().
原因也很好理解:因变量之间是没有关系的,所有因变量元素只不过是放到一起,因此可以把他们排列当做一维向量做线性加权到一个标量l上。这样的好处是梯度就和因变量的纬度无关了,之间获得了l与自变量的梯度,不需要管因变量是个什么形状的tensor。
线性回归
梯度下降方法求解参数
上式是可以求解析解的。
也可以通过线性回归的方法通过梯度下降优化待求参数。通常使用小批量随机梯度下降(mini-batch stochastic gradient descent)方法,即小批量计算平均梯度,多批量优化参数。
这里还乘以了一个学习率,相当于梯度下降方法中的step大小,刚开始可以大一点,后面要小一点。
全连接层(稠密层)


线性回归
- 构建模拟数据,确定输入(features),输入(label),参数
- 写data loader(把数据拆分成batch)
- 构建 function (net) , loss 和优化方法
- 迭代epoch求解

线性回归简洁版
数据读取

定义自己的function,需要给定参数个数和forward函数。其实是输入与输出之间的函数关系。因此,要给出输入和输出的计算方法,即forward函数。神经网络把这种函数关系用网格结构来代替。

用torch的net结构

损失

优化方法

边栏推荐
- "Measuring curve length" of CAD dream drawing
- Vs2015 secret key
- 3dsmax2018 common operations and some shortcut keys of editable polygons
- Unity ugui source code graphic
- 質量體系建設之路的分分合合
- Use assimp library to read MTL file data
- #775 Div.1 B. Integral Array 数学
- Research and forecast report on China's solution polymerized styrene butadiene rubber (SSBR) industry (2022 Edition)
- Solutions and answers for the 2021 Shenzhen cup
- mysql审计日志归档
猜你喜欢
![[groovy] closure (closure call | closure default parameter it | code example)](/img/61/754cee9a940fd4ecd446b38c2f413d.jpg)
[groovy] closure (closure call | closure default parameter it | code example)

2022 U.S. college students' mathematical modeling e problem ideas / 2022 U.S. game e problem analysis

Redis 排查大 key 的4种方法,优化必备

Pdf to DWG in CAD

UE4/UE5 虚幻引擎,材质篇(三),不同距离的材质优化

2021 higher education social cup mathematical modeling national tournament ABCD questions - problem solving ideas - Mathematical Modeling

質量體系建設之路的分分合合

PostgreSQL surpasses mysql, and the salary of "the best programming language in the world" is low

Unity get component

PostgreSQL 超越 MySQL,“世界上最好的编程语言”薪水偏低
随机推荐
Recherche de mots pour leetcode (solution rétrospective)
Unity and database
Judge the position of the monster in the role under unity3d
2022/7/1學習總結
"Measuring curve length" of CAD dream drawing
#775 Div.1 B. Integral Array 数学
[groovy] closure (closure call is associated with call method | call () method is defined in interface | call () method is defined in class | code example)
Unity shot tracking object
Unity card flipping effect
用 Jmeter 工具做个小型压力测试
Manually implement heap sorting -838 Heap sort
Common database statements in unity
54. Spiral matrix & 59 Spiral matrix II ●●
猿人学第一题
[leetcode] integer inversion [7]
Cocos2dx screen adaptation
Redis has four methods for checking big keys, which are necessary for optimization
Understand encodefloatrgba and decodefloatrgba
54. 螺旋矩阵 & 59. 螺旋矩阵 II ●●
2022/7/2做题总结