Keras save model FailedPreconditionError 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!
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.