js_reverse/机器学习/02pytorch基础语法/张量的切片操作.py
2023-07-12 23:26:55 +08:00

15 lines
346 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import torch
list_10 = [[[792, 436, 928, 303],
[809, 170, 778, 652],
[967, 520, 419, 184]],
[[402, 754, 327, 979],
[713, 926, 879, 934],
[540, 953, 209, 369]]]
t10 = torch.tensor(list_10)
# 切第一个维度为1其他维度不切
print(t10[1:, :, :])
print(t10[1:, 2:, 3].item())