what is the reason this eror


UnboundLocalError Traceback (most recent call last)
in ()
2 inputs, labels = data
3 optimizer.zero_grad()
----> 4 outputs = net(inputs)
5 loss = criterion(outputs, labels)
6 loss.backward()

1 frames
in forward(self, X)
9 self.fc3 = nn.Linear(84,10)
10 def forward(self,X):
—> 11 x = self.pool(F.relu(self.conv1(x)))
12 X = self.pool(F.relu(self.conv2(x)))
13 X = X.view(-1,1655)

UnboundLocalError: local variable ‘x’ referenced before assignment

Can you give full code? I think error due to variable assignment

1 Like

It seems you are passing X (uppercase) to forward, while using x (lowercase) in the modules.

1 Like

yes exactly what was the problem. it was solved with your help bro.thanks alot

thanks alot bro it was solved

1 Like