【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]])
相关推荐
Learner13 小时前
Python函数
开发语言·python
万行13 小时前
机器学习&第五章生成式生成器
人工智能·python·算法·机器学习
_李小白13 小时前
【Android FrameWork】延伸阅读:AMS 的 handleApplicationCrash
android·开发语言·python
没学上了13 小时前
VLM-单头自注意力机制核心逻辑
人工智能·pytorch·深度学习
万行13 小时前
机器学习&第一章
人工智能·python·机器学习·flask·计算机组成原理
实战项目13 小时前
基于PyTorch的卷积神经网络花卉识别系统
人工智能·pytorch·cnn
2301_7973122613 小时前
学习java37天
开发语言·python
WJSKad123514 小时前
果园树干识别与定位_faster-rcnn_x101-32x4d_fpn_1x_coco改进实践
python
深蓝电商API14 小时前
Scrapy中间件实战:自定义请求头和代理池实现
python·scrapy·中间件
hui函数14 小时前
Python系列Bug修复|如何解决 pip install 安装报错 invalid command ‘bdist_wheel’(缺少 wheel)问题
python·bug·pip