Hi,
I try to use the pretrained model from
GitHub
Cadene/pretrained-models.pytorch
Pretrained ConvNets for pytorch: NASNet, ResNeXt, ResNet, InceptionV4, InceptionResnetV2, Xception, DPN, etc. - Cadene/pretrained-models.pytorch
Since I am doing kaggle, I have fine tuned the model for input and output.
The code for model is shown below :
model_name = 'inceptionresnetv2' # could be fbresnet152 or inceptionresnetv2
model = pretrainedmodels.__dict__[model_name](num_classes=1000, pretrained='imagenet')
model.conv2d_1a.conv=nn.Conv2d(4, 32, kernel_size=(3, 3), stride=(2, 2), bias=False)
model.conv2d_1a.conv.weight=torch.nn.Parameter(torch.cat((temp_weight,torch.zeros(32,1,3,3)),dim=1))
num_ftrs=model.last_linear.in_features
model.last_linear = nn.Linear(num_ftrs, 28)
However, after finish training I found that the model output is not as what I expect…
Below is the code I use to show the output result :
HumanProteinDataSet=Protein_dataset(csv_file_path='./data/train.csv',data_path='./data/train')
data_for_predict=HumanProteinDataSet[100][0].unsqueeze(0)
model=model.to(device)
data_for_predict=data_for_predict.to(device)
score_predict = model(data_for_predict)
print(score_predict)
The output is show below :
tensor([[-0.3194, 0.0140, 0.1618, -0.0913, 0.0366, -0.1231, -0.4502, -0.0712,
-0.0080, 0.0742, -0.0599, -0.0142, 0.0678, -0.1697, -0.0521, 0.0022,
0.1403, 0.0693, -0.0590, 0.0724, -0.0341, -0.2073, -0.1037, -0.0398,
0.0972, -0.0673, -0.1765, 0.3367]],
device=‘cuda:0’, grad_fn=)
Since the model is multi-class classification, the final layer should be sigmoid function. So I expect the output result should not contain negative number. Is that something wrong with my code? or I have some misunderstanding about InceptionResnet?
Thank you in advance:)