技术栈

【Pytorch】torch.cat()函数

芜湖xin2024-04-19 9:27

作用

用于在指定的维度上拼接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]])
上一篇:Vue3 实现超级有趣的功能:数字增长动画!!
下一篇:python前端tkinter
相关推荐
啵啵鱼爱吃小猫咪
1 小时前
机械臂阻抗控制github项目-mujoco仿真
开发语言·人工智能·python·机器人
MaximusCoder
1 小时前
等保测评命令——Centos Linux
linux·运维·经验分享·python·安全·centos
yunyun32123
1 小时前
用Python生成艺术:分形与算法绘图
jvm·数据库·python
m0_66257797
1 小时前
高级爬虫技巧:处理JavaScript渲染(Selenium)
jvm·数据库·python
songyuc
1 小时前
【PyTorch】感觉`CrossEntropyLoss`和`BCELoss`很类似,为什么它们接收labels的shape常常不一样呢?
人工智能·pytorch·python
ℳ๓₯㎕.空城旧梦
1 小时前
Python单元测试(unittest)实战指南
jvm·数据库·python
浩子智控
2 小时前
python程序打包的文件地址处理
开发语言·python·pyqt
Jackey_Song_Odd
2 小时前
Part 1:Python语言核心 - 序列与容器
开发语言·windows·python
m0_66257797
3 小时前
Python迭代器(Iterator)揭秘:for循环背后的故事
jvm·数据库·python
热门推荐
01GitHub 镜像站点02Qwen3.5 开源全解析:从 0.8B 到 397B,代际升级 + 全场景选型指南03OpenClaw 使用和管理 MCP 完全指南04UV安装并设置国内源05AI 编程三剑客:Spec-Kit、OpenSpec、Superpowers 深度对比与实战指南06Claude Code + GLM4.7 避坑指南:解决 Unable to connect to Anthropic services07OpenClaw Control UI安全上下文访问配置08小黑课堂计算机二级WPSoffice题库软件下载安装教程(2026年3月最新版)09让 Trae IDE 智能体 “读懂”文档 Excel+PDF+DOCX :mcp-documents-reader 工具使用指南10OpenClaw macOS 完整安装与本地模型配置教程(实战版)