摘要:
基础操作¶ In [16]: import torch from IPython.core.interactiveshell import InteractiveShell InteractiveShell.ast_node_interactivity = "all" # 目标张量 (shape: 阅读全文
posted @ 2025-03-14 18:53
xiezhengcai
阅读(95)
评论(0)
推荐(0)
摘要:
返回一个原始张量交换后的视图¶ torch.permute(input, dims) → Tensor permute() 返回的是原张量的视图(view),与原张量共享内存。 transpose(dim0, dim1) 只能交换两个维度,而 permute() 可以处理多个维度。 执行 trans 阅读全文
posted @ 2025-03-14 17:34
xiezhengcai
阅读(235)
评论(0)
推荐(0)
摘要:
In [23]: from IPython.core.interactiveshell import InteractiveShell InteractiveShell.ast_node_interactivity = "all" import torch.nn.functional as F im 阅读全文
posted @ 2025-03-14 17:17
xiezhengcai
阅读(194)
评论(0)
推荐(0)
摘要:
Pytorch 中topk的用法¶ In [14]: import torch from IPython.core.interactiveshell import InteractiveShell InteractiveShell.ast_node_interactivity = "all" a = 阅读全文
posted @ 2025-03-14 16:49
xiezhengcai
阅读(113)
评论(0)
推荐(0)
摘要:
线性变换即等于与权重矩阵的相乘 阅读全文
posted @ 2025-03-14 13:12
xiezhengcai
阅读(25)
评论(0)
推荐(0)
摘要:
torch.where 会根据条件去选择元素,返回一个tensor。¶ torch.where(condition, input, other, *, out=None) → Tensor condition 是一个BoolTensor input 和 other 可以常量,也可以是张量, 返回的张 阅读全文
posted @ 2025-03-14 12:10
xiezhengcai
阅读(492)
评论(0)
推荐(0)

浙公网安备 33010602011771号