feat: add Jupyter notebook and main script for tensor operations demonstration

This commit is contained in:
fada
2025-06-12 20:16:44 +08:00
parent 97637b29a2
commit f1bc032f11
2 changed files with 254 additions and 1 deletions

19
main.py
View File

@ -1,4 +1,21 @@
import torch
import numpy as np
print(torch.__version__)
print(torch.__version__)
A = torch.tensor([[1, 2, 3], [4, 5, 6]]) # shape = (2, 3)
B0 = torch.stack([A, A], dim=0)
print("dim=0:\n", B0)
print("shape:", B0.shape)
B1 = torch.stack([A, A], dim=1)
print("dim=1:\n", B1)
print("shape:", B1.shape)
B2 = torch.stack([A, A], dim=2)
print("dim=2:\n", B2)
print("shape:", B2.shape)
np.max()