Closed SKRohit closed 4 years ago
Probably you forgot about .eval()
call for your model.
I'd recommend you to compare outputs for the same input (e.g., fixed random tensor) both for PyTorch and converted Keras model.
@nerox8664 yes I am verifying it on the same input and I am running the input in eval
mode for PyTorch model.
@nerox8664 I resolved it. I was not scaling the input image i.e. my input image was in the range [0,255] while feeding it to the model. But after dividing the image by 255 the converted model gives me proper classification output.
I had finetuned a Resnet50 for the binary classification task in PyTorch. It is performing quite well. But the converted Keras model is always choosing only one class (the class with index value 1) for images belonging to any class. I used just
transforms.Resize((224,224)), transforms.CenterCrop(224), transforms.ToTensor()
transforms in PyTorch while in Keras I am only resizing the images to (224,224).Any suggestion on what might be going wrong in Keras model? And how to resolve it?
Environment: