outof bounds error1150×439 22.1 KB
I uploaded the out of bounds error picture here.I used cross entropy loss and running my model on rafdb dataset which contain 7 labels.
` epoch = 0

# Train the model

total_step = len(train_loader)

curr_lr = learning_rate

for epoch in range(num_epochs):

    for i, (images, labels) in enumerate(train_loader):

        #images = images.to(device)

        #labels = labels.to(device)

        print(labels)

        print(labels.size())

        # Forward pass

        #print(images.size)

        outputs = model(images)

        #print(outputs)

        print(outputs.size())

        loss = criterion(outputs, labels)

        print(loss)

        # Backward and optimize

        optimizer.zero_grad()

        loss.backward()

        optimizer.step()`

It is showing error at loss function.Thanks in advance for the help.