Learn practical skills, build real-world projects, and advance your career

my-first-notebook

Use the "Run" button to execute the code.

import numpy as np
import torch
inpputs = np.array([[73, 67, 43], 
                   [91, 88, 64], 
                   [87, 134, 58], 
                   [102, 43, 37], 
                   [69, 96, 70]], dtype='float32')
targets = np.array([[56, 70], 
                    [81, 101], 
                    [119, 133], 
                    [22, 37], 
                    [103, 119]], dtype='float32')
#convert inputs and targets to tensors

inpputs = torch.from_numpy(inpputs)
targets = torch.from_numpy(targets)
print(inpputs)
print(targets)
tensor([[ 73., 67., 43.], [ 91., 88., 64.], [ 87., 134., 58.], [102., 43., 37.], [ 69., 96., 70.]]) tensor([[ 56., 70.], [ 81., 101.], [119., 133.], [ 22., 37.], [103., 119.]])
w = torch.randn(2,3, requires_grad=True)
b = torch.randn(2, requires_grad=True)

print(w)
print(b)
tensor([[-0.7959, -0.6247, -0.7196], [-1.1137, -0.5585, 1.7536]], requires_grad=True) tensor([-0.0155, -0.7035], requires_grad=True)