Files
python/Pytorch/tensor/create_tensor.py
2025-09-09 15:10:57 +08:00

29 lines
481 B
Python

import torch
a = torch.tensor(([[[[0., 0., 0.],
[0., 0., 0.]],
[[0., 1., 0.],
[0., 0., 0.]]],
[[[0., 2., 0.],
[0., 0., 0.]],
[[0., 3., 0.],
[0., 0., 0.]]]]))
print(a)
b = torch.tensor([[3., 2., 1.], [1., 2., 3.]])
c = torch.tensor([[1., 2., 3.], [4., 5., 6.]])
print(b)
times = b * c
print(times)
print(times.type())
c = torch.normal(mean=1.0, std=torch.rand(5, 5))
print(c)
d = torch.randperm(10)
print(d)