当前位置:网站首页>tensor中的append应该如何实现
tensor中的append应该如何实现
2022-07-03 02:39:00 【strawberry47】
法一:使用list append
,再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)
法二:直接使用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)
边栏推荐
- [fluent] future asynchronous programming (introduction | then method | exception capture | async, await keywords | whencomplete method | timeout method)
- GBase 8c系统表-pg_attribute
- C语言中左值和右值的区别
- "Analysis of 43 cases of MATLAB neural network": Chapter 43 efficient programming skills of neural network -- Discussion Based on the characteristics of the new version of MATLAB r2012b
- Pytorch convolution network regularization dropblock
- SQL statement
- Add MDF database file to SQL Server database, and the error is reported
- HW-初始准备
- [flutter] example of asynchronous programming code between future and futurebuilder (futurebuilder constructor setting | handling flutter Chinese garbled | complete code example)
- Return a tree structure data
猜你喜欢
[hcia]no.15 communication between VLANs
Summary of interview project technology stack
Pytorch convolution network regularization dropblock
定了,就选它
Create + register sub apps_ Define routes, global routes and sub routes
[translation] the background project has joined the CNCF incubator
Basic operation of binary tree (C language version)
xiaodi-笔记
Memory pool (understand the process of new developing space from the perspective of kernel)
4. Classes and objects
随机推荐
HTB-Devel
GBase 8c系统表-pg_amproc
Random shuffle note
[advanced ROS] Lesson 6 recording and playback in ROS (rosbag)
Pytest (6) -fixture (Firmware)
Awk from getting started to being buried (2) understand the built-in variables and the use of variables in awk
Gbase 8C function / stored procedure parameters (II)
Monitoring and management of JVM
The data in servlet is transferred to JSP page, and the problem cannot be displayed using El expression ${}
4. Classes and objects
Oauth2.0 authentication, login and access "/oauth/token", how to get the value of request header authorization (basictoken)???
GBase 8c 函数/存储过程参数(二)
Word word word
Check log4j problems using stain analysis
Gbase 8C trigger (II)
Apple releases MacOS 11.6.4 update: mainly security fixes
Xiaodi notes
Gbase 8C system table PG_ amop
where 1=1 是什么意思
GBase 8c系统表-pg_conversion