8d77bc5f267a49ed890222039f9ee058cca7f22f,keras/saving/save_test.py,TestWholeModelSaving,test_multi_output_metrics_name_stay_same,#TestWholeModelSaving#,998

Before Change


    saving and loading a model.
    
    input_ = keras.Input((4,))
    model = keras.Model(
        input_,
        [keras.layers.Softmax(name="head_0")(keras.layers.Dense(3)(input_)),
         keras.layers.Softmax(name="head_1")(keras.layers.Dense(5)(input_))])
    metric = keras.metrics.BinaryAccuracy()
    model.compile(optimizer="rmsprop",
                  loss="mse",
                  metrics={"head_0": [metric, "accuracy"]})

    // Run one iteration.
    x = np.random.rand(2, 4)
    y = {"head_0": np.random.randint(2, size=(2, 3)),

After Change


    e.g. "head_0_accuracy" should not become "head_0_head_0_accuracy" after
    saving and loading a model.
    
    with self.cached_session():
      input_ = keras.Input((4,))
      model = keras.Model(
          input_,
          [keras.layers.Softmax(name="head_0")(keras.layers.Dense(3)(input_)),
           keras.layers.Softmax(name="head_1")(keras.layers.Dense(5)(input_))])
      metric = keras.metrics.BinaryAccuracy()
      model.compile(optimizer="rmsprop",
                    loss="mse",
                    metrics={"head_0": [metric, "accuracy"]})

      // Run one iteration.
      x = np.random.rand(2, 4)
      y = {"head_0": np.random.randint(2, size=(2, 3)),
           "head_1": np.random.randint(2, size=(2, 5))}
      model.fit(x, y, verbose=0)

      // Save and reload.
      save_format = testing_utils.get_save_format()
      saved_model_dir = self._save_model_dir()
      keras.models.save_model(model, saved_model_dir, save_format=save_format)
      loaded = keras.models.load_model(saved_model_dir)

    // Make sure the metrics names from the model before saving match the loaded
    // model.
    self.assertSequenceEqual(model.metrics_names, loaded.metrics_names)

  @combinations.generate(combinations.combine(mode=["graph", "eager"]))
  def test_warning_when_saving_invalid_custom_mask_layer(self):
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 5

Instances


Project Name: keras-team/keras
Commit Name: 8d77bc5f267a49ed890222039f9ee058cca7f22f
Time: 2021-03-01
Author: scottzhu@google.com
File Name: keras/saving/save_test.py
Class Name: TestWholeModelSaving
Method Name: test_multi_output_metrics_name_stay_same


Project Name: keras-team/keras
Commit Name: 0b89570b1601f25ebb959638aa7254b9394f7694
Time: 2021-02-26
Author: scottzhu@google.com
File Name: keras/saving/saved_model/saved_model_test.py
Class Name: MetricTest
Method Name: test_custom_metric_model


Project Name: GPflow/GPflow
Commit Name: 98db3c307d617661e33f0f14595f3347fe2fb4ed
Time: 2017-10-31
Author: art.art.v@gmail.com
File Name: testing/test_methods.py
Class Name: TestSVGP
Method Name: test_q_sqrt_fixing


Project Name: keras-team/keras
Commit Name: 60c52ea766b8049c4396ad76c6f4242039c5e974
Time: 2017-05-26
Author: anis.khlif01@gmail.com
File Name: keras/models.py
Class Name:
Method Name: load_model