当前位置:网站首页>也算是學習中的小總結
也算是學習中的小總結
2022-07-06 04:33: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.進行訓練
边栏推荐
- Redis —— Redis In Action —— Redis 实战—— 实战篇一 —— 基于 Redis 的短信登录功能 —— Redis + Token 的共享 session 应用— 有代码
- tengine 内核参数
- 解决“C2001:常量中有换行符“编译问题
- ETCD数据库源码分析——etcdserver bootstrap初始化存储
- Easyrecovery靠谱不收费的数据恢复电脑软件
- QML和QWidget混合开发(初探)
- Yyds dry goods inventory OSI & tcp/ip
- 1291_Xshell日志中增加时间戳的功能
- ue5 小知识点 开启lumen的设置
- During pycharm debugging, the view is read only and pause the process to use the command line appear on the console input
猜你喜欢
In depth MySQL transactions, stored procedures and triggers
电脑钉钉怎么调整声音
Execution order of scripts bound to game objects
View 工作流程
CADD course learning (7) -- Simulation of target and small molecule interaction (flexible docking autodock)
Use sentinel to interface locally
[Zhao Yuqiang] deploy kubernetes cluster with binary package
R note prophet
During pycharm debugging, the view is read only and pause the process to use the command line appear on the console input
Selection of slow motion function
随机推荐
One question per day (Mathematics)
hashlimit速率控制
Patent | subject classification method based on graph convolution neural network fusion of multiple human brain maps
10 exemples les plus courants de gestion du trafic istio, que savez - vous?
HotSpot VM
Recommendation system (IX) PNN model (product based neural networks)
Fedora/REHL 安装 semanage
PTA tiantisai l1-078 teacher Ji's return (15 points) detailed explanation
Basic use of MySQL (it is recommended to read and recite the content)
Ue5 small knowledge points to enable the setting of lumen
The value of two date types is subtracted and converted to seconds
Hashlimit rate control
Microservice resource address
Easyrecovery靠谱不收费的数据恢复电脑软件
Path of class file generated by idea compiling JSP page
牛顿插值法
Stable Huawei micro certification, stable Huawei cloud database service practice
【Try to Hack】john哈希破解工具
How does computer nail adjust sound
11. Intranet penetration and automatic refresh