title: What am I doing incorrectly here that does leaves my accuracy as 0% in my model, even though I know my model works well on the iris data set?
body: <pre><code>model = nnet(4, 2, 1)
  criterion = nn.CrossEntropyLoss()
  optimizer = torch.optim.SGD(model.parameters(), lr=0.1)
  
  trainloader = Dataloader(dataset=dataset, batch_size = 15)
  val_loader = Dataloader(dataset=val_dataset, batch_size = 150)
  LOSS = []
  accuracy = []
  N_test = len(val_dataset)
  
  def my_trainer(epochs):
      for epoch in range(epochs):
          for x,y in trainloader:
              z = model(x)
              loss = criterion(z, y)
              loss.backward()
              optimizer.step()
              optimizer.zero_grad()
          LOSS.append(loss.item())
          correct = 0
          for x,y in val_loader:
              z = model(x)
              _, yhat = z.max(1)
              correct += (yhat == y).sum().item()
          acc = correct/N_test
          accuracy.append(acc)
      
  my_trainer(5000)
  
  </code></pre>
  <p>Updated code- I should have been using CrossEntropyLoss instead of BCE as its a multiclass problem. This might have added to my error. Now I'm gettng the error</p>
  <pre><code>1D target tensor expected, multi-target not supported&quot; 
  </code></pre>
  <p>for the line <code>loss=criterion(z,y)</code> even though y is a 1dimensional tensor for the target. Oh well, at least the accuracy problem is solved</p>