getfromcode

PyTorch深度学习开发 torch自动推断维度

AI
文章摘要

# 创建一个 2x3x4 的张量 import torch x = torch.randn(2, 3, 4) # shape: [2, 3, 4] print(x) # 自动推断第一维 y = x.view(-1,1, 4) # shape: [6, 4] print(y) print("使用-1:", y.shape)

已有 128 人浏览 发布 2026-02-08 更新 2026-09-01


# 创建一个 2x3x4 的张量
import torch
x = torch.randn(2, 3, 4) # shape: [2, 3, 4]
print(x)
# 自动推断第一维
y = x.view(-1,1, 4) # shape: [6, 4]
print(y)
print("使用-1:", y.shape)


课程购买
课程价格
金币29
290金币限时优惠会员免费
销量:0
💎 开通会员每日免费下载,比单买更划算 →
支付成功后会自动显示下载资源云盘的链接!点击链接即可下载到本地。