当前位置:网站首页>《动手学深度学习》学习笔记
《动手学深度学习》学习笔记
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结构
损失
优化方法
边栏推荐
- Recherche de mots pour leetcode (solution rétrospective)
- Unity intelligent NPC production -- pre judgment walking (method 1)
- 【acwing】240. food chain
- 中国针状焦行业发展研究与投资价值报告(2022版)
- xss注入
- Detailed explanation of the ranking of the best universities
- Number theoretic function and its summation to be updated
- 中国溶聚丁苯橡胶(SSBR)行业研究与预测报告(2022版)
- AutoCAD - Center zoom
- Establish cloth effect in 10 seconds
猜你喜欢
Unity ugui source code graphic
Emlog博客主题模板源码简约好看响应式
AutoCAD -- dimension break
2022/7/2做题总结
2022 American College Students' mathematical modeling ABCDEF problem thinking /2022 American match ABCDEF problem analysis
669. Prune binary search tree ●●
Autocad-- Real Time zoom
Redis has four methods for checking big keys, which are necessary for optimization
Manually implement heap sorting -838 Heap sort
Pdf to DWG in CAD
随机推荐
AutoCAD -- dimension break
PostgreSQL 超越 MySQL,“世界上最好的编程语言”薪水偏低
2022/7/1學習總結
Listview is added and deleted at the index
Manually implement heap sorting -838 Heap sort
UE 虚幻引擎,项目结构
#775 Div.1 C. Tyler and Strings 组合数学
Panel panel of UI
用 Jmeter 工具做个小型压力测试
AutoCAD - scaling
Lua GBK and UTF8 turn to each other
2022 thinking of mathematical modeling a problem of American college students / analysis of 2022 American competition a problem
Séparation et combinaison de la construction du système qualité
stm32Cubemx(8):RTC和RTC唤醒中断
[groovy] closure closure (customize closure parameters | customize a single closure parameter | customize multiple closure parameters | specify the default value of closure parameters)
Unity intelligent NPC production -- pre judgment walking (method 1)
Judge the position of the monster in the role under unity3d
Emlog blog theme template source code simple good-looking responsive
Unity3d learning notes
Sqlserver stored procedures pass array parameters