class_docstr: Integration tests for the pennylane.qnn.keras.KerasLayer class.
class_docstr_tok: ["Integration","tests","for","the","pennylane.qnn.keras.KerasLayer","class","."]
docstr: Test if the entire model can be successfully saved and reloaded
  using the .save() method
docstr_tok: ["Test","if","the","entire","model","can","be","successfully","saved","and","reloaded","using","the",".save","(",")","method"]
code: def test_save_whole_model(
      self, model, n_qubits, tmpdir
  ):  # pylint: disable=redefined-outer-name
      """Test if the entire model can be successfully saved and reloaded
      using the .save() method"""
      weights = model.get_weights()
  
      file = str(tmpdir) + "/model"
      model.save(file)
  
      new_model = tf.keras.models.load_model(file)
      new_weights = new_model.get_weights()
  
      assert len(weights) == len(new_weights)
      assert all(
          w.shape == nw.shape for w, nw in zip(weights, new_weights)
      )
      assert all(
          tf.math.reduce_all(w == nw)
          for w, nw in zip(weights, new_weights)
      )
  
      # assert that the results are the same
      x = tf.constant(np.arange(5 * n_qubits).reshape(5, n_qubits))
      res = model(x)
      new_res = new_model(x)
      assert tf.math.reduce_all(res == new_res)
  
imports: from collections import defaultdict
  import numpy
  import pytest
  import pennylane
label_desc: Use image node_id 4 for calling the TestKerasLayerIntegration obj's underlying member method code with example usage: obj.test_save_whole_model(model, n_qubits, tmpdir) without return types