Learn practical skills, build real-world projects, and advance your career
Updated 4 years ago
import numpy as np
import torch
torch.tensor(([1,2,3,4],[5,6,7,8]))
tensor([[1, 2, 3, 4],
[5, 6, 7, 8]])
torch.zeros(3,3)
tensor([[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]])
torch.ones(4,4)
tensor([[1., 1., 1., 1.],
[1., 1., 1., 1.],
[1., 1., 1., 1.],
[1., 1., 1., 1.]])
torch.eye(4)
tensor([[1., 0., 0., 0.],
[0., 1., 0., 0.],
[0., 0., 1., 0.],
[0., 0., 0., 1.]])