【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]])
相关推荐
shangyingying_12 分钟前
图像质量评价(IQA)
人工智能·python·神经网络
OPEN-Source3 分钟前
大模型 Agent 实战:多 Agent 太贵太慢?一套系统性的性能与成本优化方案
人工智能·python·agent·rag·deepseek
一阵寒风4 分钟前
ComfyUI本地部署指南
开发语言·人工智能·python
高洁0111 分钟前
大模型架构演进:从Transformer到MoE
python·深度学习·机器学习·数据挖掘·知识图谱
谁不学习揍谁!13 分钟前
基于python机器学习算法的农作物产量可视化分析预测系统(完整系统源码+数据库+详细文档+论文+详细部署教程+答辩PPT)获取方式
python·算法·机器学习
OPEN-Source19 分钟前
别为多 Agent 而多 Agent:一套实用的 Agent 架构选型指南
人工智能·python·agent·rag·deepseek
ID_1800790547331 分钟前
Python采集京东商品详情:基于官方API的规格与价格获取
开发语言·数据库·python
一次旅行32 分钟前
测开每日AI提效指令(Python+pytest专属)
python·pytest·测试总结
Suryxin.32 分钟前
从0开始复现nano-vllm「ModelRunner.capture_cudagraph()」
人工智能·pytorch·深度学习·vllm
大猫子的技术日记1 小时前
Playwright 自动化测试入门指南:Python 开发者的端到端实战
开发语言·人工智能·python