I have made a switch from TensorFlow to PyTorch recently. I use a famous Github repo for training on EfficientNets
. I wrote the model initiation class as follows:
class CustomEfficientNet(nn.Module):
def __init__(self, config: type, pretrained: bool=True):
super().__init__()
self.config = config
self.model = geffnet.create_model(
model_name='EfficientNetB5',
pretrained=pretrained)
n_features = self.model.classifier.in_features
self.model.classifier = nn.Linear(n_features, num_classes=5)
def forward(self, input_neurons):
output_predictions = self.model(input_neurons)
return output_predictions
In addition, in my transforms
, I tend to useResize(img_size = 512, img_size=512)
for my training on certain image classification tasks (Mostly Kaggle Competitions). So the question here is, the official input size for EfficientNetB5
is 456x456, but I used 512x512 or even 256x256 and get very decent results. Is this normal? Or did I miss out the source code where the author will resize into the native resolution for you?
PS: This seems to be the norm in all the PyTorch Tutorials I saw on Kaggle. My full code can be seen here in this notebook here; I like to not leave logic gaps and therefore this question popped up.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…