Thanks for your reply, i imported the model as
model = models.segmentation.fcn_resnet101(pretrained= True, aux_loss=False)
for param in model.parameters():
param.requires_grad=False
model.classifier[4] = nn.Conv2d(512, 2, kernel_size=(1, 1), stride=(1, 1))
model.aux_classifier = None
… i have changed the line u suggested to
with torch.set_grad_enabled(True):
outputs = model(inputs)
print(type(outputs))
labels = labels.long()
loss = criterion(outputs[‘out’], labels)
_, preds = torch.max(outputs, 1)
but getting this error :
TypeError: max() received an invalid combination of arguments - got (collections.OrderedDict, int), but expected one of:

(Tensor input)
(Tensor input, name dim, bool keepdim, *, tuple of Tensors out)
(Tensor input, Tensor other, *, Tensor out)
(Tensor input, int dim, bool keepdim, *, tuple of Tensors out)