title: how to save best weights and best model using keras
body: <p>Experts, I'm new to the machine learning and using Keras API with TensorFlow back-end to train a machine learning model. I'm using Model-checkpoint to save best weights and best model in .json and .h5 file independently.in so far I tried to write a code as below but i am not getting any model or weights saved. Hope i will get good solution.Thanks in advance.</p>
  <pre><code>    filepath1=&quot;best_weights.h5&quot;
      filepath2=&quot;best_model.json&quot;
      checkpoint = ModelCheckpoint(filepath1, monitor='val_acc', verbose=1, save_best_only=True,  mode='max')
      callbacks_list = [checkpoint]
      history = model.fit_generator(train_generator,steps_per_epoch=nb_train_samples // batch_size, epochs=epochs, validation_data=validation_generator, callbacks=callbacks_list, validation_steps=nb_validation_samples // batch_size, verbose=1)
      
  </code></pre>