weights: one of `None` or 'imagenet'

2,050 views
Skip to first unread message

ganab...@gmail.com

unread,
Oct 29, 2017, 11:15:52 PM10/29/17
to Keras-users
Hello

I have done with training and got my model(weight). Now i want to use that model for extracting features (or prediction)
But the architectures from Keras (such as vgg, xception,...) only allow to use imagenet pre-trained model.
Must i create my own architectures to use my pre-trained models?
Or keras still provides source that allows us to use our own weight? if yes where is that source and how to use it?

Error: 
if weights not in {'imagenet', None}:
raise ValueError('The `weights` argument should be either '
'`None` (random initialization) or `imagenet` '
'(pre-training on ImageNet).')

My code:

weights='./data/checkpoints/Xception-.001-0.588_2.hdf5'

base_model = Xception(
                weights=weights,
                include_top=True
                )

Matias Valdenegro

unread,
Oct 30, 2017, 3:43:04 AM10/30/17
to keras...@googlegroups.com
If you have a trained model, you can use it directly for feature extraction by
building a function that computer a given layer output given the input. which
is covered in the Keras FAQ.

I am not sure why you introduce the pre-trained imagenet models, they
literally have nothing to do with what you are trying to do.

ganab...@gmail.com

unread,
Oct 30, 2017, 9:06:05 PM10/30/17
to Keras-users
Thank you for your reply.

The code above is how to use pre-trained weight. 
But the architectures only allow imagenet weight in keras code. this is what i meant.

Anyway succeeded,.. i had to build all architectures by myself to use my own weight. 

SHEFALI

unread,
Nov 6, 2020, 2:54:20 PM11/6/20
to Keras-users
How did you solve this problem? Can you explain it briefly

Alok Das

unread,
Oct 26, 2022, 5:46:26 PM10/26/22
to Keras-users
weights='./data/checkpoints/Xception-.001-0.588_2.hdf5'

base_model =  weights  (
                weights="none",
                include_top=True
                )
Reply all
Reply to author
Forward
0 new messages