Question regarding top_model_weights_path
Sanjay-Reddy-S opened this issue · 5 comments
Hi, I'm pretty new to deep-learning and keras in general. I want to know about that top-model weights file (Line No: 34). Where do I get that file (can you attach it)? or how do I train to get that .h5 file? I followed that blog.keras.io post but his top layer is different from yours and also he is training on dog vs cat (only 2 labels) whereas you are training on a dataset having ten output labels. I in fact tried modifying his code by replacing his top layer with your specifications. When I use the resulting bottleneck_fc_model.h5 as the file for your program, some dimension mismatch error is occurring. Any help?
The top model is defined in the lines 114-123 of the code.
You cannot use the h5 file of my model in a model with a different architecture. Line 34 only defines the path to save the top model parameters after training, you don't need it to train a new model, you only need the file of the VGG-16.
But then, line 120 [ top_model.load_weights(top_model_weights_path) ] throws an error. If you just put a path where you want to save the parameters, how will the top_model "load" weights?
[The exact traceback is as follows:
Traceback (most recent call last):
File "HumanActionRecognition.py", line 347, in
top_model.load_weights(top_model_weights_path)
File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 2486, in load_weights
f = h5py.File(filepath, mode='r')
File "/usr/local/lib/python2.7/dist-packages/h5py/_hl/files.py", line 272, in init
fid = make_fid(name, mode, userblock_size, fapl, swmr=swmr)
File "/usr/local/lib/python2.7/dist-packages/h5py/_hl/files.py", line 92, in make_fid
fid = h5f.open(name, flags, fapl=fapl)
File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper (/tmp/pip-4rPeHA-build/h5py/_objects.c:2684)
File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper (/tmp/pip-4rPeHA-build/h5py/_objects.c:2642)
File "h5py/h5f.pyx", line 76, in h5py.h5f.open (/tmp/pip-4rPeHA-build/h5py/h5f.c:1930)
IOError: Unable to open file (Unable to open file: name = '/home/pixel/downloads/fc_model.h5', errno = 2, error message = 'no such file or directory', flags = 0, o_flags = 0)
]
OK, I uploaded the pre-trained weights of the top-model. Let me know if the code is working fine now. Thank you for your contribution!
Thanx a lot!!