当前位置:网站首页>torch.cat()使用方法
torch.cat()使用方法
2022-08-11 05:35:00 【Pr4da】
torch.cat()
可以对tensor进行上下或左右拼接,其传入的参数为:
torch.cat(tensors, dim=0)
dim
控制拼接的维度,dim=0
为上下拼接,dim=1
为左右拼接1。
下面是实例详解:
>>> import torch
>>> a = torch.rand((2,3))
>>> a
tensor([[0.7515, 0.1021, 0.0726],
[0.0575, 0.1666, 0.2763]])
>>> b = torch.rand((2,3))
>>> b
tensor([[0.7485, 0.8340, 0.2617],
[0.7847, 0.2847, 0.3445]])
>>> c =torch.cat((a,b),dim=0)
>>> c
tensor([[0.7515, 0.1021, 0.0726],
[0.0575, 0.1666, 0.2763],
[0.7485, 0.8340, 0.2617],
[0.7847, 0.2847, 0.3445]])
>>> d = torch.cat((a,b),dim=1)
>>> d
tensor([[0.7515, 0.1021, 0.0726, 0.7485, 0.8340, 0.2617],
[0.0575, 0.1666, 0.2763, 0.7847, 0.2847, 0.3445]])
本文原载于我的简书。
边栏推荐
猜你喜欢
随机推荐
Arcgis小工具_实现重叠分析
WiFi Deauth 攻击演示分析 // mdk4 // aireplay-ng// Kali // wireshark //
局域网文件传输
slurm cluster construction
空间点模式方法_一阶效应和二阶效应
vnc远程桌面安装(2021-10-20日亲测可用)
ETCD cluster fault emergency recovery - local data is available
Concurrent programming in eight-part essay
China Mobile Communications Group Co., Ltd.: Business Power of Attorney
bash的命令退出状态码
buildroot嵌入式文件系统中vi显示行号
ovnif摄像头修改ip
buildroot设置dhcp
HCIA实验
HCIP-Spanning Tree (802.1D, Standard Spanning Tree/802.1W: RSTP Rapid Spanning Tree/802.1S: MST Multiple Spanning Tree)
Class definition, class inheritance, and the use of super
Threatless Technology-TVD Daily Vulnerability Intelligence-2022-8-2
类的定义、类的继承以及super的使用
CLUSTER DAY02 (Keepalived Hot Standby, Keepalived+LVS, HAProxy Server)
从mask-rcnn到shp