当前位置:网站首页>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]])
本文原载于我的简书。
边栏推荐
猜你喜欢
Xshell如何连接虚拟机
MySQL01
CLUSTER DAY01 (Introduction to cluster and LVS, LVS-NAT cluster, LVS-DR cluster)
升级到Window11体验
Solve win10 installed portal v13 / v15 asked repeatedly to restart problem.
CLUSTER DAY02( Keepalived热备 、 Keepalived+LVS 、 HAProxy服务器 )
查看CPU和其他硬件温度的软件
OA项目之会议通知(查询&是否参会&反馈详情)
SECURITY DAY06 ( iptables firewall, filter table control, extended matching, typical application of nat table)
核方法 Kernel method
随机推荐
MoreFileRename批量文件改名工具
CLUSTER DAY03 (Ceph overview, the deployment of Ceph CLUSTER, Ceph block storage)
OA项目之待开会议&历史会议&所有会议
arcgis填坑_1
阿里巴巴规范之POJO类中布尔类型的变量都不要加is前缀详解
Es common operations and classical case
Memory debugging tools Electric Fence
pytorch下tensorboard可视化深坑
SECURITY DAY04 (Prometheus server, Prometheus monitored terminal, Grafana, monitoring database)
Raspberry Pi set static IP address
利用opencv读取图片,重命名。
HCIP experiments (pap, chap, HDLC, MGRE, RIP)
【LeetCode】1036. 逃离大迷宫(思路+题解)压缩矩阵+BFS
MoreFileRename batch file renaming tool
Basic use of Slurm
FusionCompute8.0.0实验(0)CNA及VRM安装(2280v2)
HCIP MPLS/BGP Comprehensive Experiment
八股文之mysql
查看CPU和其他硬件温度的软件
No threat of science and technology - TVD vulnerability information daily - 2022-7-21