Hi there. I trained a VGG network using CIFAR10 dataset first for transfer learning.
After I save the model of CIFAR 10 VGG network.
I substituted the classifier due to another dataset has different class number.

Then I start to train the model with the new dataset.
def train(epoch):
    print('\nEpoch: %d' % epoch)
    net.train()
    train_loss = 0
    correct = 0
    total = 0
    for batch_idx, (inputs, targets) in enumerate(trainloader):
        inputs, targets = inputs.to(device), targets.to(device)
        optimizer.zero_grad()
        outputs = net(inputs)
        loss = criterion(outputs, targets)
        loss.backward()
        optimizer.step()

        train_loss += loss.item()
        _, predicted = outputs.max(1)
        total += targets.size(0)
        correct += predicted.eq(targets).sum().item()

        progress_bar(batch_idx, len(trainloader), 'Loss: %.3f | Acc: %.3f%% (%d/%d)'
            % (train_loss/(batch_idx+1), 100.*correct/total, correct, total))

train(net)

However, there is an error.

image.png707×260 9.53 KB

I cannot get the point from the error message. Can you help me fix that? Many thanks.