I’m failing to pass a simple tensor into a simple deep nn.
What am I doing wrong?
ERROR MESSAGE:
“RuntimeError: mat1 and mat2 shapes cannot be multiplied (1x2 and 1x128)”
import numpy as np
import torch as t
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
class DNN(nn.Module):
def __init__ (self,input=1,h1=128,output=1):
super().__init__()
self.input = input
self.h1 = h1
self.output = output
self.fc1 = nn.Linear(input,h1)
self.fc2 = nn.Linear(h1,output)
def forward(self,kiwi):
out = F.relu(self.fc1(kiwi))
out = self.fc2(out)
return out
dnn = DNN()
data = t.tensor([1,2])
dnn.forward(data)