Learn practical skills, build real-world projects, and advance your career
import torch
import numpy as np

the training data can be represented using 2 matrices: inputs and targets, each with one row per observation and one column per variable.

#input (temp, rainfall, humidity)
inputs = np.array([[73, 67, 43],
                  [91, 88, 64],
                  [87, 134, 58],
                  [102, 43, 37],
                  [69, 96, 70]], dtype = 'float32')
# targets (apples, oranges)
targets = np.array([[56, 70],
                  [81, 101],
                  [119, 133],
                  [22, 37],
                  [103, 119]], dtype = 'float32')
#converting numpy to PyTorch
inputs = torch.from_numpy(inputs)
targets = torch.tensor(targets)
print(inputs)
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.]])