code: def test_fit_restore():
      """Test specifying restore=True when calling fit()."""
      n_data_points = 10
      n_features = 2
      X = np.random.rand(n_data_points, n_features)
      y = (X[:, 0] > X[:, 1]).astype(np.float32)
      dataset = dc.data.NumpyDataset(X, y)
  
      # Train a model to overfit the dataset.
  
      keras_model = tf.keras.Sequential(
          [
              tf.keras.layers.Dense(10, activation="relu"),
              tf.keras.layers.Dense(1, activation="sigmoid"),
          ]
      )
      model = dc.models.KerasModel(
          keras_model,
          dc.models.losses.BinaryCrossEntropy(),
          learning_rate=0.005,
      )
      model.fit(dataset, nb_epoch=1000)
      prediction = np.squeeze(model.predict_on_batch(X))
      assert np.array_equal(y, np.round(prediction))
  
      # Create an identical model, do a single step of fitting with restore=True,
      # and make sure it got restored correctly.
  
      keras_model2 = tf.keras.Sequential(
          [
              tf.keras.layers.Dense(10, activation="relu"),
              tf.keras.layers.Dense(1, activation="sigmoid"),
          ]
      )
      model2 = dc.models.KerasModel(
          keras_model2,
          dc.models.losses.BinaryCrossEntropy(),
          model_dir=model.model_dir,
      )
      model2.fit(dataset, nb_epoch=1, restore=True)
      prediction = np.squeeze(model2.predict_on_batch(X))
      assert np.array_equal(y, np.round(prediction))
  
file_path: deepchem/deepchem/models/tests/test_kerasmodel.py
imports: import os
  import math
  import deepchem
  import numpy
  import unittest
  import pytest
label_desc: Use image node_id 6 for calling a global function with example usage: test_fit_restore() without return types