当前位置:网站首页>也算是學習中的小總結
也算是學習中的小總結
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.進行訓練
边栏推荐
- Can Flink SQL read multiple topics at the same time. How to write in with
- 2/12 didn't learn anything
- How do programmers teach their bosses to do things in one sentence? "I'm off duty first. You have to work harder."
- Several important classes in unity
- [network] channel attention network and spatial attention network
- 1291_Xshell日志中增加时间戳的功能
- tengine 内核参数
- P2102 地砖铺设(dfs&贪心)
- ETCD数据库源码分析——etcdserver bootstrap初始化存储
- How many of the 10 most common examples of istio traffic management do you know?
猜你喜欢
When debugging after pycharm remote server is connected, trying to add breakpoint to file that does not exist: /data appears_ sda/d:/segmentation
Stable Huawei micro certification, stable Huawei cloud database service practice
MySQL learning record 13 database connection pool, pooling technology, DBCP, c3p0
Query the number and size of records in each table in MySQL database
MLAPI系列 - 04 - 网络变量和网络序列化【网络同步】
canal同步mysql数据变化到kafka(centos部署)
Understanding of processes, threads, coroutines, synchronization, asynchrony, blocking, non blocking, concurrency, parallelism, and serialization
Solve the compilation problem of "c2001: line breaks in constants"
Stable Huawei micro certification, stable Huawei cloud database service practice
ETCD数据库源码分析——etcdserver bootstrap初始化存储
随机推荐
[Zhao Yuqiang] deploy kubernetes cluster with binary package
Easyrecovery靠谱不收费的数据恢复电脑软件
P2102 floor tile laying (DFS & greed)
Basic explanation of turtle module - draw curve
Sorting out the latest Android interview points in 2022 to help you easily win the offer - attached is the summary of Android intermediate and advanced interview questions in 2022
Stable Huawei micro certification, stable Huawei cloud database service practice
2327. Number of people who know secrets (recursive)
Lombok principle and the pit of ⽤ @data and @builder at the same time
10個 Istio 流量管理 最常用的例子,你知道幾個?
After learning classes and objects, I wrote a date class
Practical development of member management applet 06 introduction to life cycle function and user-defined method
Microservice resource address
VPP性能测试
关于进程、线程、协程、同步、异步、阻塞、非阻塞、并发、并行、串行的理解
【Try to Hack】john哈希破解工具
食品行业仓储条码管理系统解决方案
Comprehensive ability evaluation system
[face recognition series] | realize automatic makeup
The implementation of the maize negotiable digital warehouse receipt standard will speed up the asset digitization process of the industry
Cross domain and jsonp details