Commit 7faea226 authored by Bharath Ramsundar's avatar Bharath Ramsundar
Browse files

Merge branch 'master' of https://github.com/deepchem/deepchem into pddbind_load

parents 215e2f11 797b1ccf
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -113,6 +113,7 @@ class MultitaskClassifier(TensorGraph):
      prev_layer = layer

    # Compute the loss function for each label.
    self.neural_fingerprint = prev_layer

    logits = Reshape(
        shape=(-1, n_tasks, n_classes),
@@ -257,6 +258,7 @@ class MultitaskRegressor(TensorGraph):
      if dropout > 0.0:
        layer = Dropout(dropout, in_layers=[layer])
      prev_layer = layer
    self.neural_fingerprint = prev_layer

    # Compute the loss function for each label.

+10 −4
Original line number Diff line number Diff line
@@ -643,7 +643,7 @@ class GraphConvModel(TensorGraph):
    batch_norm3 = BatchNorm(in_layers=[dense])
    if self.dropout[-1] > 0.0:
      batch_norm3 = Dropout(self.dropout[-1], in_layers=batch_norm3)
    readout = GraphGather(
    self.neural_fingerprint = GraphGather(
        batch_size=self.batch_size,
        activation_fn=tf.nn.tanh,
        in_layers=[batch_norm3, self.degree_slice, self.membership] +
@@ -657,7 +657,9 @@ class GraphConvModel(TensorGraph):
      logits = Reshape(
          shape=(None, n_tasks, n_classes),
          in_layers=[
              Dense(in_layers=readout, out_channels=n_tasks * n_classes)
              Dense(
                  in_layers=self.neural_fingerprint,
                  out_channels=n_tasks * n_classes)
          ])
      logits = TrimGraphOutput([logits, weights])
      output = SoftMax(logits)
@@ -669,13 +671,17 @@ class GraphConvModel(TensorGraph):
      labels = Label(shape=(None, n_tasks))
      output = Reshape(
          shape=(None, n_tasks),
          in_layers=[Dense(in_layers=readout, out_channels=n_tasks)])
          in_layers=[
              Dense(in_layers=self.neural_fingerprint, out_channels=n_tasks)
          ])
      output = TrimGraphOutput([output, weights])
      self.add_output(output)
      if self.uncertainty:
        log_var = Reshape(
            shape=(None, n_tasks),
            in_layers=[Dense(in_layers=readout, out_channels=n_tasks)])
            in_layers=[
                Dense(in_layers=self.neural_fingerprint, out_channels=n_tasks)
            ])
        log_var = TrimGraphOutput([log_var, weights])
        var = Exp(log_var)
        self.add_variance(var)
+19 −0
Original line number Diff line number Diff line
@@ -62,6 +62,25 @@ class TestGraphModels(unittest.TestCase):
    assert np.allclose(scores['mean-roc_auc_score'],
                       scores2['mean-roc_auc_score'])

  def test_neural_fingerprint_retrieval(self):
    tasks, dataset, transformers, metric = self.get_dataset(
        'classification', 'GraphConv')

    fp_size = 3

    batch_size = 50
    model = GraphConvModel(
        len(tasks),
        batch_size=batch_size,
        dense_layer_size=3,
        mode='classification')

    model.fit(dataset, nb_epoch=1)
    neural_fingerprints = model.predict(
        dataset, outputs=model.neural_fingerprint)
    neural_fingerprints = np.array(neural_fingerprints)[:len(dataset)]
    self.assertEqual((len(dataset), fp_size * 2), neural_fingerprints.shape)

  def test_graph_conv_regression_model(self):
    tasks, dataset, transformers, metric = self.get_dataset(
        'regression', 'GraphConv')