当前位置:网站首页>How to implement append in tensor
How to implement append in tensor
2022-07-03 02:43:00 【strawberry47】
Law 1 : Use list append
, Again concat
import torch
T1 = torch.tensor([1,2,5,4]).unsqueeze_(0)
T2 = torch.tensor([1,2,3,4]).unsqueeze_(0)
T3 = torch.tensor([2,2,3,4]).unsqueeze_(0)
a = []
a.append(T1)
a.append(T2)
a.append(T3)
c = torch.cat(a,dim=0)
Law two : Use it directly concat
for i in range(12):
b = torch.randn(3)
b.unsqueeze_(0)
if i == 0:
a = b
else:
a = torch.cat((a, b), dim=0)
边栏推荐
- Gbase 8C system table PG_ am
- Gbase 8C system table PG_ cast
- [Hcia]No.15 Vlan间通信
- Didi programmers are despised by relatives: an annual salary of 800000 is not as good as two teachers
- JS的装箱和拆箱
- The data in servlet is transferred to JSP page, and the problem cannot be displayed using El expression ${}
- GBase 8c系统表-pg_conversion
- 定了,就选它
- Apple releases MacOS 11.6.4 update: mainly security fixes
- Counter统计数量后,如何返回有序的key
猜你喜欢
oauth2.0鉴权,登录访问 “/oauth/token”,请求头Authorization(basicToken)如何取值???
Add automatic model generation function to hade
ASP. Net core 6 framework unveiling example demonstration [02]: application development based on routing, MVC and grpc
Principle and application of database
What does "where 1=1" mean
easyPOI
A2L file parsing based on CAN bus (2)
Deep Reinforcement Learning for Intelligent Transportation Systems: A Survey 论文阅读笔记
Can netstat still play like this?
HTB-Devel
随机推荐
QT qcombobox add qccheckbox (drop-down list box insert check box, including source code + comments)
Gbase 8C system table PG_ collation
Gbase 8C system table PG_ amop
基于can总线的A2L文件解析(2)
JS的装箱和拆箱
Monitoring and management of JVM
Source code analysis | layout file loading process
[hcia]no.15 communication between VLANs
Gbase 8C trigger (II)
MATLAB小技巧(24)RBF,GRNN,PNN-神经网络
SQL statement
[translation] modern application load balancing with centralized control plane
二维格式数组格式索引下标连续问题导致 返回json 格式问题
Gbase 8C function / stored procedure definition
HTB-Devel
HW initial preparation
简单理解svg
Source code analysis | resource loading resources
sql server 查詢指定錶的錶結構
GBase 8c 触发器(一)