Resnet models return sparse feature vectors for non-classification purposes
The higher the model size the lesser the sparsity, for example Resnet-50 returns something like this: 1.21183541e-04 3.07215611e-03 4.77146730e-02 1.17256586e-03 0.00000000e+00 2.89303549e-02 2.75966304e-04 4.31401143e-03 0.00000000e+00 5.60556509e-05 0.00000000e+00 1.35882914e-01 0.00000000e+00 0.00000000e+00 4.15335549e-03 2.52501760e-03 0.00000000e+00 ...
The feature representations do not make sense, I have tried VGG and InceptionResnetV2, which seem to be working fine and achieve right accuracies with the exact same code, but Resnet only seems to be working well for classification tasks (as in the given example code).
# tensorflow/Models/Resnet
with slim.arg_scope(resnet_utils.resnet_arg_scope()):
prelogits, end_points = resnet_v1.resnet_v1_101(image_batch, is_training=phase_train_placeholder,
global_pool = True, num_classes=None)
# tensorflow/Models/vgg_16
prelogits, end_points = vgg_16(image_batch,
num_classes=args.embedding_size,
is_training=phase_train_placeholder,
dropout_keep_prob=0.5,
spatial_squeeze=True,
scope='vgg_16',
fc_conv_padding='VALID')
# tensorflow/Models/InceptionResnetV2
with slim.arg_scope(inception_utils.inception_arg_scope()):
prelogits, end_points = inception_resnet_v2.inception_resnet_v2(image_batch, is_training=phase_train_placeholder,
num_classes=args.embedding_size)
@panyx0718 Can you comment on this?
I was comparing the feature vectors with Torch resnet, turns out the torch resnet model is claimed to work better, as on the facebook-torch-resnet repository. Even then, this Tensorflow resnet performs very bad when compared to something like VGG, for the purpose of feature extraction; also this is the case with all Resnets V1 and V2, and InceptionResnets as well. At least for me.
@nathansilberman Looks like it's the slim's model.
@Shubhamcl It would be great to point out code location so that we can find someone to help you
Thanks!
Yes I am referring to the slim model, RESNET V1 50 under directory: https://github.com/tensorflow/models/tree/master/research/slim
Here I illustrate the behavior, although it is in keras, I saw the same in Tensorflow: https://github.com/Shubhamcl/torch_vs_kerasTF/blob/master/keras_tf.ipynb
Here I illustrate the behavior in torch: https://github.com/Shubhamcl/torch_vs_kerasTF/blob/master/torch.ipynb
This is an old issue, from over a year ago. It deals with speed comparisons resnet, keras and torch for this model. Hence we close.