text_plain_output_1.png
import numpy as np

import torch

t1 = torch.tensor(4.0)
t1

t2 = torch.tensor([1.0, 2, 3, 4])
t2

t3 = torch.tensor([[5.0, 6], [7, 8], [9, 10]])
t3

t4 = torch.tensor([[[11, 12, 13], [13, 14, 15]], [[15, 16, 17], [17, 18, 19.0]]])
t4

x = torch.tensor(3.0)
w = torch.tensor(4.0, requires_grad=True)
b = torch.tensor(5.0, requires_grad=True)

y = w * x + b
y

y.backward()

import numpy as np
x = np.array([[1, 2], [3, 4]])
x

y = torch.from_numpy(x)
y

(x.dtype, y.dtype)

z = y.numpy()
z