【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]])
相关推荐
yaoh.wang3 分钟前
力扣(LeetCode) 67: 二进制求和 - 解法思路
python·程序人生·算法·leetcode·面试·职场和发展·跳槽
电饭叔15 分钟前
自定义重载运算符--《python语言程序设计》2018版--第8章20题使用Rational类求和数列之一
开发语言·python
Evan芙18 分钟前
基于Nginx和Python的动态站点安装配置
数据库·python·nginx
工具人555520 分钟前
python 环境问题
开发语言·python
小鸡吃米…22 分钟前
Python编程语言面试问题三
开发语言·python·面试
yaoh.wang26 分钟前
力扣(LeetCode) 58: 最后一个单词的长度 - 解法思路
python·程序人生·算法·leetcode·面试·职场和发展·跳槽
深蓝海拓28 分钟前
PySide6从0开始学习的笔记(七) 控件(Widget)之文字输入类控件
笔记·python·qt·学习·pyqt
free-elcmacom29 分钟前
机器学习高阶教程<4>因果机器学习:因果推断、可解释AI与科学发现的新革命
人工智能·python·机器学习·因果机器学习
smile_Iris30 分钟前
Day 41 早停策略和模型权重的保存
开发语言·python
淮北49433 分钟前
图神经网络与pytorch
人工智能·pytorch·神经网络