Commit 7f90f0eb authored by abster12's avatar abster12
Browse files

Remove the old commits

parent 645a3496
Loading
Loading
Loading
Loading
+0 −15
Original line number Diff line number Diff line
@@ -797,21 +797,6 @@ class GraphConvModel(TensorGraph):
          d[self.deg_adjs[i - 1]] = multiConvMol.get_deg_adjacency_lists()[i]
        yield d

  def create_estimator_inputs(self, feature_columns, weight_column, features,
                              labels, mode):
    tensors = {}
    for layer, columm in zip(
        [self.atom_features, self.degree_slice, self.membership,self.deg_adjs],
        feature_columns):
      tensors[layer] = tf.feature_column.input_layer(features, [column])
    if weight_column is not None:
      tensor[self.my_task_weights[0]] = tf.feature_column.input_layer(
          features, [weight_column])
    if labels is not None:
      tensors[self.labels[0]] = tf.cast(labels, tf.int32)

    return tensors

  def predict_on_generator(self, generator, transformers=[], outputs=None):
    if not self.built:
      self.build()
+0 −51
Original line number Diff line number Diff line
@@ -328,54 +328,3 @@ class TestEstimators(unittest.TestCase):
    results = estimator.evaluate(input_fn=lambda: input_fn(1))
    assert results['loss'] < 0.5
    assert results['accuracy'] > 0.6


  def test_Graphconvmodel(self):

    n_tasks = 1
    n_samples=10
    n_features = 3

    np.random.seed(123)
    X=np.random.rand(n_tasks)
    y=np.zeros((n_tasks))
    dataset= dc.data.NumpyDataset(X,y)

    def input_fn(epochs):

        x, y, weights = dataset.make_iterator(
          batch_size=n_samples, epochs=epochs).get_next()
        return {'x': x, 'weights': weights}, y

    model = dc.models.GraphConvModel(n_tasks,graph_conv_layers=[64,64],dense_layer_size=128,dropout = 0.0,mode = 'classification', number_atom_features = 75)

    x_col = tf.feature_column.numeric_column('x', shape=(n_features,))
    weight_col = tf.feature_column.numeric_column('weights', shape=(n_tasks,))

    def accuracy(labels, predictions, weights):
      return tf.metrics.accuracy(labels, tf.round(predictions), weights)


    metrics = {'accuracy': accuracy}
    estimator = model.make_estimator(
        feature_columns=[x_col], weight_column=weight_col, metrics=metrics)


    estimator.train(input_fn=lambda: input_fn(100))


    results = estimator.evaluate(input_fn=lambda: input_fn(1))
    assert results['loss'] < 1e-4
    assert results['accuracy'] > 0.9