code: def test_overfit_graph_model():
      """Test fitting a KerasModel defined as a graph."""
      n_data_points = 10
      n_features = 2
      np.random.seed(1234)
      X = np.random.rand(n_data_points, n_features)
      y = (X[:, 0] > X[:, 1]).astype(np.float32)
      dataset = dc.data.NumpyDataset(X, y)
      inputs = tf.keras.Input(shape=(n_features,))
      hidden = tf.keras.layers.Dense(10, activation="relu")(inputs)
      logits = tf.keras.layers.Dense(1)(hidden)
      outputs = tf.keras.layers.Activation("sigmoid")(logits)
      keras_model = tf.keras.Model(
          inputs=inputs, outputs=[outputs, logits]
      )
      model = dc.models.KerasModel(
          keras_model,
          dc.models.losses.SigmoidCrossEntropy(),
          output_types=["prediction", "loss"],
          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))
      metric = dc.metrics.Metric(dc.metrics.roc_auc_score)
      scores = model.evaluate(dataset, [metric])
      assert scores[metric.name] > 0.9
  
      # Check that predicting internal layers works.
      pred_logits = np.squeeze(
          model.predict_on_batch(X, outputs=logits)
      )
      pred_from_logits = 1.0 / (1.0 + np.exp(-pred_logits))
      assert np.allclose(prediction, pred_from_logits, atol=1e-4)
  
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 1 for calling a global function with example usage: test_overfit_graph_model() without return types