question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use pretrained models.

See original GitHub issue

I try to load pretrained model but get zero accuracy in the begining. In train.py I am doing the following way:

` sym, arg_params, aux_params = mx.model.load_checkpoint(os.path.join(args.pretrained, “model”), args.pretrained_epoch) sym = get_symbol(args) model = mx.mod.Module( context=ctx, symbol=sym, ) model.bind(data_shapes=train_dataiter.provide_data, label_shapes=train_dataiter.provide_label) model.set_params(arg_params, aux_params)

model.fit(train_dataiter,
    num_epoch=999999,
    eval_data=val_dataiter,
    eval_metric=eval_metrics,
    kvstore=args.kvstore,
    optimizer=opt,
    initializer=initializer,
    allow_missing=True,
    batch_end_callback=_batch_callback,
    arg_params=arg_params,
    aux_params=aux_params)`

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
JokaHDcommented, Nov 20, 2019

Hi @vkasojhaa, I think it’s ok. But the default output of the model with fc7 layer is classification results. I guess it is necessary to get internal layer after load checkpoint for extracting features. see Extract Features in https://github.com/dmlc/mxnet-notebooks/blob/master/python/how_to/predict.ipynb

1reaction
JokaHDcommented, Nov 18, 2019

Hi @vkasojhaa, Generally, we take the output of embedding layer as feature of an image. Then calculate cosine similarity between two features as their similarity. fc7_weight is only used while training and validating. It is used for classifying an input image to a certain class. If the person is not in your training set, it impossible to get correct result. That’s why we use cosine similarity.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Transfer Learning | Pretrained Models in Deep Learning
Train some layers while freeze others – Another way to use a pre-trained model is to train is partially. What we can do...
Read more >
Transfer learning from pre-trained models | by Pedro Marcelino
4. Transfer learning process · Select a pre-trained model. · Classify your problem according to the Size-Similarity Matrix. In Figure 3 you have...
Read more >
How to use a pre-trained deep learning model - Educative.io
Points to consider before moving on to the implementation · Import the required libraries · Load the model · Load the image ·...
Read more >
Transfer learning and fine-tuning | TensorFlow Core
A pre-trained model is a saved network that was previously trained on a large dataset, typically on a large-scale image-classification task. You either...
Read more >
Using pretrained deep learning model as feature extractor for ...
Code associated with these tutorials can be downloaded from here: https://github.com/bnsreenu/python_for_image_processing_APEER.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found