当前位置:网站首页>也算是学习中的小总结
也算是学习中的小总结
2022-07-06 04:32:00 【成娃子】
#以下代码都是在jupyter notebook中运行的
import torch
c=torch.arange(20).reshape(2,5,2)
c,c.sum(axis=0) #(2,5,2)第一个2消失,两个(5,2)相加
#运行结果
(tensor([[[ 0, 1],
[ 2, 3],
[ 4, 5],
[ 6, 7],
[ 8, 9]],
[[10, 11],
[12, 13],
[14, 15],
[16, 17],
[18, 19]]]),
tensor([[10, 12],
[14, 16],
[18, 20],
[22, 24],
[26, 28]]))
c=torch.arange(20).reshape(2,5,2)
c,c.sum(axis=1) #(2,5,2)第二个5消失,两个(5,2)变成(1,2)再相加
#运行结果
(tensor([[[ 0, 1],
[ 2, 3],
[ 4, 5],
[ 6, 7],
[ 8, 9]],
[[10, 11],
[12, 13],
[14, 15],
[16, 17],
[18, 19]]]),
tensor([[20, 25],
[70, 75]]))
c=torch.arange(20).reshape(2,5,2)
c,c.sum(axis=2) #(2,5,2)第三个2消失,变成(2,5)
#运行结果
(tensor([[[ 0, 1],
[ 2, 3],
[ 4, 5],
[ 6, 7],
[ 8, 9]],
[[10, 11],
[12, 13],
[14, 15],
[16, 17],
[18, 19]]]),
tensor([[ 1, 5, 9, 13, 17],
[21, 25, 29, 33, 37]]))
c=torch.arange(20).reshape(2,5,2)
c,c.sum(axis=1,keepdims=True).shape
#运行截图
(tensor([[[ 0, 1],
[ 2, 3],
[ 4, 5],
[ 6, 7],
[ 8, 9]],
[[10, 11],
[12, 13],
[14, 15],
[16, 17],
[18, 19]]]),
torch.Size([2, 1, 2]))
线性回归模型的步骤
1.生成数据集。
2.读取数据集。
3.初始化模型参数。
4.定义模型
5.损失函数
6.优化算法
7.进行训练
边栏推荐
- Is the mode of education together - on campus + off campus reliable
- [Chongqing Guangdong education] engineering fluid mechanics reference materials of southwestjiaotonguniversity
- One question per day (Mathematics)
- Recommendation | recommendation of 9 psychotherapy books
- 2328. 网格图中递增路径的数目(记忆化搜索)
- 【HBZ分享】云数据库如何定位慢查询
- Unity screen coordinates ugui coordinates world coordinates conversion between three coordinate systems
- CADD课程学习(7)-- 模拟靶点和小分子相互作用 (柔性对接 AutoDock)
- SharedPreferences source code analysis
- When debugging after pycharm remote server is connected, trying to add breakpoint to file that does not exist: /data appears_ sda/d:/segmentation
猜你喜欢
Visio draws Tai Chi
1291_Xshell日志中增加时间戳的功能
Basic use of MySQL (it is recommended to read and recite the content)
coreldraw2022新版本新功能介绍cdr2022
Figure application details
Path of class file generated by idea compiling JSP page
R note prophet
Introduction to hashtable
Slow SQL fetching and analysis of MySQL database
How to solve the problem of slow downloading from foreign NPM official servers—— Teach you two ways to switch to Taobao NPM image server
随机推荐
P3500 [POI2010]TES-Intelligence Test(二分&离线)
MySQL learning record 13 database connection pool, pooling technology, DBCP, c3p0
[Zhao Yuqiang] deploy kubernetes cluster with binary package
[Chongqing Guangdong education] Suzhou University English film and Television Appreciation reference materials
P2022 有趣的数(二分&数位dp)
ue5 小知识点 开启lumen的设置
2328. 网格图中递增路径的数目(记忆化搜索)
颠覆你的认知?get和post请求的本质
Path of class file generated by idea compiling JSP page
newton interpolation
CADD course learning (8) -- virtual screening of Compound Library
Crawler notes: improve data collection efficiency! Use of proxy pool and thread pool
Dynamic programming (tree DP)
Hashlimit rate control
word封面下划线
Figure application details
[tomato assistant installation]
Cross domain and jsonp details
QML和QWidget混合开发(初探)
Explain in simple terms node template parsing error escape is not a function