【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]])
相关推荐
0思必得022 分钟前
[Web自动化] CSS基础概念和介绍
前端·css·python·自动化·html·web自动化
计算机徐师兄24 分钟前
Python基于Django的MOOC线上课程推荐数据分析与可视化系统(附源码,文档说明)
python·数据分析·django·慕课线上课程推荐·慕课线上课程推荐可视化系统·pytho线上课程推荐可视化·线上课程推荐数据分析可视化系统
free-elcmacom27 分钟前
Python实战项目<2>使用Graphviz绘制流程框图
开发语言·python·graphviz
ljuncong34 分钟前
python的装饰器怎么使用
开发语言·python
该用户已不存在1 小时前
没有这7款工具,难怪你的Python这么慢
后端·python
serve the people1 小时前
tensorflow 零基础吃透:RaggedTensor 的不规则形状与广播机制 2
人工智能·python·tensorflow
Hello.Reader1 小时前
Flink ML 基本概念Table API、Stage、Pipeline 与 Graph
大数据·python·flink
chen_note1 小时前
Python面向对象、并发编程、网络编程
开发语言·python·网络编程·面向对象·并发编程
信看1 小时前
树莓派CAN(FD) 测试&&RS232 RS485 CAN Board 测试
开发语言·python
brent4231 小时前
DAY24推断聚类后簇的类型
python