Learn practical skills, build real-world projects, and advance your career
!conda install pytorch cpuonly -c pytorch -y
import torch
import numpy as np
Collecting package metadata (current_repodata.json): ...working... done Solving environment: ...working... done # All requested packages already installed.
# input(temp,Rainfall and Humidity)
inputs=np.array([[73,67,43],[91,88,64],[87,134,58],[102,43,37],[69,96,70]],dtype='float32')
#targets
targets=np.array([[56,70],[81,101],[119,133],[22,37],[103,119]])
#ConvertInputs and Targets to tensors
inputs=torch.from_numpy(inputs)
targets=torch.from_numpy(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]], dtype=torch.int32)
#Weights and biases
w=torch.randn(2,3,requires_grad=True)
b=torch.randn(2,requires_grad=True)
print(w)
print(b)
tensor([[ 2.3725, 1.2009, -0.2889], [ 0.0716, -0.1936, 0.9446]], requires_grad=True) tensor([0.6080, 0.0954], requires_grad=True)