当前位置:网站首页>《动手学深度学习》学习笔记
《动手学深度学习》学习笔记
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结构

损失

优化方法

边栏推荐
- [groovy] closure closure (customize closure parameters | customize a single closure parameter | customize multiple closure parameters | specify the default value of closure parameters)
- 2021 electrician Cup - high speed rail traction power supply system operation data analysis and equivalent modeling ideas + code
- Thinking of 2022 American College Students' mathematical modeling competition
- XSS injection
- 2021-10-29
- 【Leetcode】1352. Product of the last K numbers
- 中国溶聚丁苯橡胶(SSBR)行业研究与预测报告(2022版)
- [groovy] closure (closure call | closure default parameter it | code example)
- AutoCAD - workspace settings
- Unity and database
猜你喜欢

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

Emlog博客主题模板源码简约好看响应式

On-off and on-off of quality system construction
![[groovy] closure (Introduction to closure class closure | closure parametertypes and maximumnumberofparameters member usage)](/img/1b/1fa2ebc9a6c5d271c9b39f5e508fb0.jpg)
[groovy] closure (Introduction to closure class closure | closure parametertypes and maximumnumberofparameters member usage)
![[groovy] closure (closure parameter binding | curry function | rcurry function | ncurry function | code example)](/img/90/0cf08ae6fea61891e3e1fdf29d310c.jpg)
[groovy] closure (closure parameter binding | curry function | rcurry function | ncurry function | code example)

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

Create a pyGame window with a blue background

Looking at Chinese science and technology from the Winter Olympics: what is the mystery of the high-speed camera that the whole people thank?

2022/7/2 question summary

Solutions and answers for the 2021 Shenzhen cup
随机推荐
Is $20billion a little less? Cisco is interested in Splunk?
Lua GBK and UTF8 turn to each other
C4D simple cloth (version above R21)
用 Jmeter 工具做个小型压力测试
2021 electrician cup idea + code - photovoltaic building integration plate index development trend analysis and prediction: prediction planning issues
Basic knowledge points
Unity3d learning notes
【acwing】240. food chain
2022 U.S. college students' mathematical modeling e problem ideas / 2022 U.S. game e problem analysis
LeetCode之单词搜索(回溯法求解)
Pdf to DWG in CAD
AutoCAD - full screen display
Unity synergy
China as resin Market Research and investment forecast report (2022 Edition)
Unity writes timetables (without UI)
2022 thinking of mathematical modeling D problem of American college students / analysis of 2022 American competition D problem
【Leetcode】1352. 最后 K 个数的乘积
django连接数据库报错,这是什么原因
PostgreSQL 超越 MySQL,“世界上最好的编程语言”薪水偏低
Lua wechat avatar URL