VQA-Demo-GUI icon indicating copy to clipboard operation
VQA-Demo-GUI copied to clipboard

this function:get_VQA_model(VQA_weights_file_name),I got a error

Open lianglili opened this issue 4 years ago • 0 comments

Function :

def get_VQA_model(VQA_weights_file_name): ''' Given the VQA model and its weights, compiles and returns the model ''' vqa_model = VQA_MODEL()

vqa_model.load_weights(VQA_weights_file_name)        *********  Running this line, I have a bug.****
vqa_model.compile(loss=keras.losses.categorical_crossentropy,
                  optimizer=keras.optimizers.Adadelta(),
                  metrics=['accuracy'])
return vqa_model

Error Information:

Traceback (most recent call last): File "E:/pycharm-workspace/VQA-Demo-GUI-master/VQA-VGG-16+LSTM-GUI.py", line 246, in start_prediction vqa_model = get_VQA_model(model,VQA_weights_file_name) File "E:/pycharm-workspace/VQA-Demo-GUI-master/VQA-VGG-16+LSTM-GUI.py", line 73, in get_VQA_model vqa_model.load_weights(VQA_weights_file_name) File "C:\Users\lucky\Anaconda3\lib\site-packages\tensorflow\python\keras\engine\training.py", line 162, in load_weights return super(Model, self).load_weights(filepath, by_name) File "C:\Users\lucky\Anaconda3\lib\site-packages\tensorflow\python\keras\engine\network.py", line 1411, in load_weights self._assert_weights_created() File "C:\Users\lucky\Anaconda3\lib\site-packages\tensorflow\python\keras\engine\network.py", line 1673, in _assert_weights_created self.name) ValueError: Weights for model sequential_2 have not yet been created. Weights are created when the Model is first called on inputs or build() is called with an input_shape.

please help me. Thanks a lot!

lianglili avatar Sep 29 '20 08:09 lianglili