当前位置:网站首页>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]])
边栏推荐
- 解决win10安装portal v13/v15要求反复重启问题。
- MySQL之CRUD
- AUTOMATION DAY07( Ansible Vault 、 普通用户使用ansible)
- SECURITY DAY02 (Zabbix alarm mechanism, Zabbix advanced operation and monitoring case)
- HCIP OSPF/MGRE Comprehensive Experiment
- Eight-legged text jvm
- CLUSTER DAY02 (Keepalived Hot Standby, Keepalived+LVS, HAProxy Server)
- iptables的状态
- CLUSTER DAY01 (Introduction to cluster and LVS, LVS-NAT cluster, LVS-DR cluster)
- uboot sets the default bootdelay
猜你喜欢
随机推荐
ansible批量安装zabbix-agent
arcgis填坑_4
Open Set Domain Adaptation 开集领域适应
使用路由器DDNS功能+动态公网IP实现外网访问(花生壳)
CLUSTER DAY02 (Keepalived Hot Standby, Keepalived+LVS, HAProxy Server)
arcgis填坑_3
MySQL之CRUD
ETCD Single-Node Fault Emergency Recovery
HCIA experiment
【LeetCode】306.累加数(思路+题解)
FusionCompute8.0.0实验(1)CNA及VRM安装
cloudreve使用体验
SECURITY DAY02 (Zabbix alarm mechanism, Zabbix advanced operation and monitoring case)
HCIP-生成树(802.1D ,标准生成树/802.1W : RSTP 快速生成树/802.1S : MST 多生成树)
Sturges规则
【LeetCode】851.喧闹与富有(思路+题解)
SECURITY DAY04 (Prometheus server, Prometheus monitored terminal, Grafana, monitoring database)
配置dns服务
lvm multi-disk mount, combined use
CLUSTER DAY03( Ceph概述 、 部署Ceph集群 、 Ceph块存储)