【Pytorch】torch.cat()函数

作用

用于在指定的维度上拼接tensor(张量)。

导入

python 复制代码
import torch

用法

python 复制代码
tensor1 = torch.tensor([[1, 2], [3, 4]])
tensor2 = torch.tensor([[5, 6], [7, 8]])
result = torch.cat((tensor1, tensor2), dim=0)

# result:
# tensor([[1, 2],
#        [3, 4],
#        [5, 6],
#        [7, 8]])
相关推荐
2401_8288906416 分钟前
使用 BERT 实现意图理解和实体识别
人工智能·python·自然语言处理·bert·transformer
多恩Stone1 小时前
【3DV 进阶-2】Hunyuan3D2.1 训练代码详细理解下-数据读取流程
人工智能·python·算法·3d·aigc
xiaopengbc2 小时前
在 Python 中实现观察者模式的具体步骤是什么?
开发语言·python·观察者模式
Python大数据分析@2 小时前
python用selenium怎么规避检测?
开发语言·python·selenium·网络爬虫
ThreeAu.2 小时前
Miniconda3搭建Selenium的python虚拟环境全攻略
开发语言·python·selenium·minicoda·python环境配置
偷心伊普西隆2 小时前
Python EXCEL 理论探究:格式转换时处理缺失值方法
python·excel
Francek Chen2 小时前
【深度学习计算机视觉】03:目标检测和边界框
人工智能·pytorch·深度学习·目标检测·计算机视觉·边界框
九章云极AladdinEdu2 小时前
AI集群全链路监控:从GPU微架构指标到业务Metric关联
人工智能·pytorch·深度学习·架构·开源·gpu算力