当前位置:网站首页>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]])
本文原载于我的简书。
边栏推荐
- My approval of OA project (inquiry & meeting signature)
- HCIP OSPF dynamic routing protocol
- My meeting of the OA project (meeting seating & review)
- vnc远程桌面安装(2021-10-20日亲测可用)
- uboot sets the default bootdelay
- Class definition, class inheritance, and the use of super
- MySQL之函数
- 八股文之并发编程
- Basic use of Slurm
- 华为防火墙-4-安全策略
猜你喜欢
随机推荐
iptables 流量统计
ETCD cluster fault emergency recovery - to recover from the snapshot
华为防火墙-4-安全策略
Threatless Technology-TVD Daily Vulnerability Intelligence-2022-8-2
arcgis填坑_2
slurm集群搭建
Eight-legged text of mysql
Top20括号匹配
HCIP BGP built adjacent experiment
HCIP MGRE\OSPF综合实验
OA项目之项目简介&会议发布
SECURITY DAY01 (Monitoring Overview, Zabbix Basics, Zabbix Monitoring Services)
arcmap下的多进程脚本
【LeetCode】306.累加数(思路+题解)
SATA、SAS、SSD三种硬盘存储性能数据
SECURITY DAY04 (Prometheus server, Prometheus monitored terminal, Grafana, monitoring database)
HCIP-BGP的选路实验
bash的命令退出状态码
cloudreve使用体验
华为防火墙-1-安全区域