Feature extraction Using Pretrained Models

Your code is quite hard to read since you haven’t formatted it properly.
From the first look it seems these parts might be wrong:

(‘output’, nn.Softmax(dim=0))])).cuda()
criterion = nn.CrossEntropyLoss()

nn.CrossEntropyLoss expects raw logits, so remove the Softmax layer.

    scores=max(scores)
    loss = criterion(scores, targets)

I don’t know why max is used here instead of passing the logits to the criterion directly.