2
$\begingroup$

Model works and fits. After adding model.save('model.h5'). I am receiving tensorflow.python.framework.errors_impl.FailedPreconditionError: Attempting to use uninitialized value dense_11/bias[[Node: _retval_dense_11/bias_0_0 = _RetvalT=DT_FLOAT, index=0, _device="/job:localhost/replica:0/task:0/device:CPU:0"]]

I tried model.save_weights('model.h5') saves the model but after trying to load the model I get:

KeyError: "Unable to open object (object 'dense_12' doesn't exist)"

After saving model to json and then trying to load it i get json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0).

What should I do? Thanks for help!

$\endgroup$
2
  • 1
    $\begingroup$ Are you trying to load this saved weights into a newly created network with same architecture and then it is throwing this error? $\endgroup$ – Kiritee Gak Dec 29 '18 at 7:28
  • $\begingroup$ You need to redefine the architecture exactly in the similar fashion $\endgroup$ – Aditya Dec 29 '18 at 7:32
3
$\begingroup$

The error was caused because after training the model I opened another tensorflow session to save predictions to dataset and put model.save('model.h5') after. So moving this line up, right after the model finished training solved the problem.

$\endgroup$
1
  • $\begingroup$ you should accept your own answer if that was what solved the problem described in the question. Next time you should also add a snippet of the code you are using to describe what happened in the code so that other users could figure out what was the problem as well. Also, consider adding the lines of code that were the problem and the ones that were the solution. $\endgroup$ – wacax Jan 1 '19 at 19:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.