当前位置:网站首页>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]])
边栏推荐
- HCIA实验
- 华为防火墙-7-dhcp
- SECURITY DAY06 ( iptables firewall, filter table control, extended matching, typical application of nat table)
- HPC平台搭建
- 【LeetCode】2034. 股票价格波动(思路+题解)双map
- 推荐一个好用的IDEA插件---Translation—中英互译
- cloudreve使用体验
- CLUSTER DAY02( Keepalived热备 、 Keepalived+LVS 、 HAProxy服务器 )
- uboot code analysis 1: find the main line according to the purpose
- The ramdisk practice 1: the root file system integrated into the kernel
猜你喜欢

Memory debugging tools Electric Fence

ETCD cluster fault emergency recovery - local data is available

HCIP BGP built adjacent experiment

内存调试工具Electric Fence

CLUSTER DAY01 (Introduction to cluster and LVS, LVS-NAT cluster, LVS-DR cluster)

MySQl进阶之索引结构

SECURITY DAY04( Prometheus服务器 、 Prometheus被监控端 、 Grafana 、 监控数据库)

会议OA项目之我的会议

本地yum源搭建

cloudreve使用体验
随机推荐
HPC平台搭建
MoreFileRename batch file renaming tool
CLUSTER DAY02 (Keepalived Hot Standby, Keepalived+LVS, HAProxy Server)
iptables的状态
lvm multi-disk mount, combined use
China Mobile Communications Group Co., Ltd.: Business Power of Attorney
arcgis填坑_2
Numpy_备注
HCIA知识复习
HCIP MGRE\OSPF综合实验
Class definition, class inheritance, and the use of super
Eight-legged text jvm
Raspberry Pi set static IP address
八股文之mysql
SECURITY DAY06 ( iptables firewall, filter table control, extended matching, typical application of nat table)
Arcgis小工具_实现重叠分析
【LeetCode】851.喧闹与富有(思路+题解)
OA项目之会议通知(查询&是否参会&反馈详情)
查看CPU和其他硬件温度的软件
deepin v20.6+cuda+cudnn+anaconda(miniconda)