当前位置:网站首页>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]])
本文原载于我的简书。
边栏推荐
猜你喜欢
随机推荐
中国移动通信集团有限公司:业务委托书
OA项目之会议通知(查询&是否参会&反馈详情)
Basic use of Slurm
China Mobile Communications Group Co., Ltd.: Business Power of Attorney
View the library ldd that the executable depends on
SECURITY DAY04 (Prometheus server, Prometheus monitored terminal, Grafana, monitoring database)
解决win10安装portal v13/v15要求反复重启问题。
HCIP MPLS/BGP Comprehensive Experiment
HCIA experiment
(2) Software Testing Theory (*Key Use Case Method Writing)
SECURITY DAY05(Kali系统 、 扫描与抓包 、 SSH基本防护、服务安全 )
HCIP BGP built adjacent experiment
HCIP MGRE\OSPF综合实验
训练分类器
CLUSTER DAY02( Keepalived热备 、 Keepalived+LVS 、 HAProxy服务器 )
内存调试工具Electric Fence
Windos10专业版开启远程桌面协助
局域网文件传输
OA项目之我的审批(查询&会议签字)
防火墙-0-管理地址









