当前位置:网站首页>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]])
边栏推荐
猜你喜欢
TOP2两数相加
MoreFileRename批量文件改名工具
Slurm基本使用
CLUSTER DAY02 (Keepalived Hot Standby, Keepalived+LVS, HAProxy Server)
buildroot嵌入式文件系统中vi显示行号
HCIP-Spanning Tree (802.1D, Standard Spanning Tree/802.1W: RSTP Rapid Spanning Tree/802.1S: MST Multiple Spanning Tree)
(2) Software Testing Theory (*Key Use Case Method Writing)
【LeetCode】851.喧闹与富有(思路+题解)
SECURITY DAY06( iptables防火墙 、 filter表控制 、 扩展匹配、nat表典型应用 )
HCIP WPN实验
随机推荐
arcgis填坑_4
pytorch下tensorboard可视化深坑
Memory debugging tools Electric Fence
AUTOMATION DAY07( Ansible Vault 、 普通用户使用ansible)
vi display line number in buildroot embedded file system
照片的35x45,300dpi怎么弄
OA Project Pending Meeting & History Meeting & All Meetings
AUTOMATION DAY06 (Ansible Advanced, Ansible Role)
AUTOMATION DAY06( Ansible进阶 、 Ansible Role)
会议OA项目之我的会议
TOP2 Add two numbers
ETCD cluster fault emergency recovery - to recover from the snapshot
MySQl进阶之索引结构
FusionCompute8.0.0实验(0)CNA及VRM安装(2280v2)
ansible batch install zabbix-agent
vnc远程桌面安装(2021-10-20日亲测可用)
Top20括号匹配
利用opencv读取图片,重命名。
HCIP WPN实验
SECURITY DAY01(监控概述 、 Zabbix基础 、 Zabbix监控服 )