Commit 0b78522e authored by miaecle's avatar miaecle
Browse files

debug

parent 3f3e8b7a
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -573,6 +573,20 @@ class Concat(Layer):
    return out_tensor


class Stack(Layer):

  def __init__(self, axis=1, **kwargs):
    self.axis = axis
    super(Stack, self).__init__(**kwargs)

  def create_tensor(self, in_layers=None, set_tensors=True, **kwargs):
    inputs = self._get_input_tensors(in_layers)
    out_tensor = tf.stack(inputs, axis=self.axis)
    if set_tensors:
      self.out_tensor = out_tensor
    return out_tensor
    
    
class Constant(Layer):
  """Output a constant value."""

+12 −5
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ from deepchem.metrics import to_one_hot, from_one_hot
from deepchem.models.tensorgraph.graph_layers import WeaveLayer, WeaveGather, \
    Combine_AP, Separate_AP, DTNNEmbedding, DTNNStep, DTNNGather, DAGLayer, DAGGather, DTNNExtract
from deepchem.models.tensorgraph.layers import Dense, Concat, SoftMax, SoftMaxCrossEntropy, GraphConv, BatchNorm, \
    GraphPool, GraphGather, WeightedError, BatchNormalization
    GraphPool, GraphGather, WeightedError, BatchNormalization, Stack
from deepchem.models.tensorgraph.layers import L2Loss, Label, Weights, Feature
from deepchem.models.tensorgraph.tensor_graph import TensorGraph
from deepchem.trans import undo_transforms
@@ -103,7 +103,10 @@ class WeaveTensorGraph(TensorGraph):
        self.labels_fd.append(label)
        cost = L2Loss(in_layers=[label, regression])
        costs.append(cost)
    if self.mode == "classification":
      all_cost = Concat(in_layers=costs, axis=1)
    elif self.mode == "regression":
      all_cost = Stack(in_layers=costs, axis=1)
    self.weights = Weights(shape=(None, self.n_tasks))
    loss = WeightedError(in_layers=[all_cost, self.weights])
    self.set_loss(loss)
@@ -256,7 +259,7 @@ class DTNNTensorGraph(TensorGraph):
      cost = L2Loss(in_layers=[label, regression])
      costs.append(cost)

    all_cost = Concat(in_layers=costs, axis=1)
    all_cost = Stack(in_layers=costs, axis=1)
    self.weights = Weights(shape=(None, self.n_tasks))
    loss = WeightedError(in_layers=[all_cost, self.weights])
    self.set_loss(loss)
@@ -401,8 +404,10 @@ class DAGTensorGraph(TensorGraph):
        self.labels_fd.append(label)
        cost = L2Loss(in_layers=[label, regression])
        costs.append(cost)

    if self.mode == "classification":
      all_cost = Concat(in_layers=costs, axis=1)
    elif self.mode == "regression":
      all_cost = Stack(in_layers=costs, axis=1)
    self.weights = Weights(shape=(None, self.n_tasks))
    loss = WeightedError(in_layers=[all_cost, self.weights])
    self.set_loss(loss)
@@ -537,8 +542,10 @@ class GraphConvTensorGraph(TensorGraph):
        self.my_labels.append(label)
        cost = L2Loss(in_layers=[label, regression])
        costs.append(cost)

    if self.mode == "classification":
      entropy = Concat(in_layers=costs, axis=-1)
    elif self.mode == "regression":
      entropy = Stack(in_layers=costs, axis=1)
    self.my_task_weights = Weights(shape=(None, self.n_tasks))
    loss = WeightedError(in_layers=[entropy, self.my_task_weights])
    self.set_loss(loss)
@@ -595,7 +602,7 @@ class GraphConvTensorGraph(TensorGraph):
    if not self.built:
      self.build()
    return self.evaluate_generator(
        self.default_generator(dataset),
        self.default_generator(dataset, predict=True),
        metrics,
        labels=self.my_labels,
        weights=[self.my_task_weights])
+3 −3
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ Created on Thu Jul 6 20:31:47 2017
import numpy as np
import tensorflow as tf

from deepchem.models.tensorgraph.layers import Dense, Concat, WeightedError
from deepchem.models.tensorgraph.layers import Dense, Concat, WeightedError, Stack
from deepchem.models.tensorgraph.layers import L2Loss, Label, Weights, Feature
from deepchem.models.tensorgraph.tensor_graph import TensorGraph
from deepchem.models.tensorgraph.graph_layers import DTNNEmbedding
@@ -69,7 +69,7 @@ class BPSymmetryFunctionRegression(TensorGraph):
      cost = L2Loss(in_layers=[label, output])
      costs.append(cost)

    all_cost = Concat(in_layers=costs, axis=0)
    all_cost = Stack(in_layers=costs, axis=1)
    self.weights = Weights(shape=(None, self.n_tasks))
    loss = WeightedError(in_layers=[all_cost, self.weights])
    self.set_loss(loss)
@@ -158,7 +158,7 @@ class ANIRegression(TensorGraph):
      cost = L2Loss(in_layers=[label, output])
      costs.append(cost)

    all_cost = Concat(in_layers=costs, axis=0)
    all_cost = Stack(in_layers=costs, axis=1)
    self.weights = Weights(shape=(None, self.n_tasks))
    loss = WeightedError(in_layers=[all_cost, self.weights])
    self.set_loss(loss)
+2 −0
Original line number Diff line number Diff line
@@ -276,6 +276,8 @@ class TensorGraph(Model):
          result = np.array(sess.run(out_tensors, feed_dict=feed_dict))
          if len(result.shape) == 3:
            result = np.transpose(result, axes=[1, 0, 2])
          if self.mode == 'regression':
            result = np.squeeze(result, 2)
          result = undo_transforms(result, transformers)
          results.append(result)
        return np.concatenate(results, axis=0)
+25 −2
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@ CheckFeaturizer = {
    ('bace_c', 'tf'): ['ECFP', 1024],
    ('bace_c', 'tf_robust'): ['ECFP', 1024],
    ('bace_c', 'rf'): ['ECFP', 1024],
    ('bace_c', 'kernelsvm'): ['ECFP', 1024],
    ('bace_c', 'irv'): ['ECFP', 1024],
    ('bace_c', 'xgb'): ['ECFP', 1024],
    ('bace_c', 'graphconv'): ['GraphConv', 75],
@@ -12,6 +13,7 @@ CheckFeaturizer = {
    ('bbbp', 'tf'): ['ECFP', 1024],
    ('bbbp', 'tf_robust'): ['ECFP', 1024],
    ('bbbp', 'rf'): ['ECFP', 1024],
    ('bbbp', 'kernelsvm'): ['ECFP', 1024],
    ('bbbp', 'irv'): ['ECFP', 1024],
    ('bbbp', 'xgb'): ['ECFP', 1024],
    ('bbbp', 'graphconv'): ['GraphConv', 75],
@@ -21,6 +23,7 @@ CheckFeaturizer = {
    ('clintox', 'tf'): ['ECFP', 1024],
    ('clintox', 'tf_robust'): ['ECFP', 1024],
    ('clintox', 'rf'): ['ECFP', 1024],
    ('clintox', 'kernelsvm'): ['ECFP', 1024],
    ('clintox', 'irv'): ['ECFP', 1024],
    ('clintox', 'xgb'): ['ECFP', 1024],
    ('clintox', 'graphconv'): ['GraphConv', 75],
@@ -30,6 +33,7 @@ CheckFeaturizer = {
    ('hiv', 'tf'): ['ECFP', 1024],
    ('hiv', 'tf_robust'): ['ECFP', 1024],
    ('hiv', 'rf'): ['ECFP', 1024],
    ('hiv', 'kernelsvm'): ['ECFP', 1024],
    ('hiv', 'irv'): ['ECFP', 1024],
    ('hiv', 'xgb'): ['ECFP', 1024],
    ('hiv', 'graphconv'): ['GraphConv', 75],
@@ -39,6 +43,7 @@ CheckFeaturizer = {
    ('muv', 'tf'): ['ECFP', 1024],
    ('muv', 'tf_robust'): ['ECFP', 1024],
    ('muv', 'rf'): ['ECFP', 1024],
    ('muv', 'kernelsvm'): ['ECFP', 1024],
    ('muv', 'irv'): ['ECFP', 1024],
    ('muv', 'xgb'): ['ECFP', 1024],
    ('muv', 'graphconv'): ['GraphConv', 75],
@@ -49,7 +54,6 @@ CheckFeaturizer = {
    ('pcba', 'logreg'): ['ECFP', 1024],
    ('pcba', 'tf'): ['ECFP', 1024],
    ('pcba', 'tf_robust'): ['ECFP', 1024],
    ('pcba', 'rf'): ['ECFP', 1024],
    ('pcba', 'irv'): ['ECFP', 1024],
    ('pcba', 'xgb'): ['ECFP', 1024],
    ('pcba', 'graphconv'): ['GraphConv', 75],
@@ -58,6 +62,7 @@ CheckFeaturizer = {
    ('sider', 'tf'): ['ECFP', 1024],
    ('sider', 'tf_robust'): ['ECFP', 1024],
    ('sider', 'rf'): ['ECFP', 1024],
    ('sider', 'kernelsvm'): ['ECFP', 1024],
    ('sider', 'irv'): ['ECFP', 1024],
    ('sider', 'xgb'): ['ECFP', 1024],
    ('sider', 'graphconv'): ['GraphConv', 75],
@@ -70,6 +75,7 @@ CheckFeaturizer = {
    ('tox21', 'tf'): ['ECFP', 1024],
    ('tox21', 'tf_robust'): ['ECFP', 1024],
    ('tox21', 'rf'): ['ECFP', 1024],
    ('tox21', 'kernelsvm'): ['ECFP', 1024],
    ('tox21', 'irv'): ['ECFP', 1024],
    ('tox21', 'xgb'): ['ECFP', 1024],
    ('tox21', 'graphconv'): ['GraphConv', 75],
@@ -82,83 +88,100 @@ CheckFeaturizer = {
    ('toxcast', 'tf'): ['ECFP', 1024],
    ('toxcast', 'tf_robust'): ['ECFP', 1024],
    ('toxcast', 'rf'): ['ECFP', 1024],
    ('toxcast', 'kernelsvm'): ['ECFP', 1024],
    ('toxcast', 'irv'): ['ECFP', 1024],
    ('toxcast', 'xgb'): ['ECFP', 1024],
    ('toxcast', 'graphconv'): ['GraphConv', 75],
    ('toxcast', 'weave'): ['Weave', 75],
    ('bace_r', 'tf_regression'): ['ECFP', 1024],
    ('bace_r', 'rf_regression'): ['ECFP', 1024],
    ('bace_r', 'krr'): ['ECFP', 1024],
    ('bace_r', 'xgb_regression'): ['ECFP', 1024],
    ('bace_r', 'graphconvreg'): ['GraphConv', 75],
    ('bace_r', 'dag_regression'): ['GraphConv', 75],
    ('bace_r', 'weave_regression'): ['Weave', 75],
    ('chembl', 'tf_regression'): ['ECFP', 1024],
    ('chembl', 'rf_regression'): ['ECFP', 1024],
    ('chembl', 'krr'): ['ECFP', 1024],
    ('chembl', 'xgb_regression'): ['ECFP', 1024],
    ('chembl', 'graphconvreg'): ['GraphConv', 75],
    ('chembl', 'weave_regression'): ['Weave', 75],
    ('clearance', 'tf_regression'): ['ECFP', 1024],
    ('clearance', 'rf_regression'): ['ECFP', 1024],
    ('clearance', 'krr'): ['ECFP', 1024],
    ('clearance', 'xgb_regression'): ['ECFP', 1024],
    ('clearance', 'graphconvreg'): ['GraphConv', 75],
    ('clearance', 'dag_regression'): ['GraphConv', 75],
    ('clearance', 'weave_regression'): ['Weave', 75],
    ('delaney', 'tf_regression'): ['ECFP', 1024],
    ('delaney', 'rf_regression'): ['ECFP', 1024],
    ('delaney', 'krr'): ['ECFP', 1024],
    ('delaney', 'xgb_regression'): ['ECFP', 1024],
    ('delaney', 'graphconvreg'): ['GraphConv', 75],
    ('delaney', 'dag_regression'): ['GraphConv', 75],
    ('delaney', 'weave_regression'): ['Weave', 75],
    ('hopv', 'tf_regression'): ['ECFP', 1024],
    ('hopv', 'rf_regression'): ['ECFP', 1024],
    ('hopv', 'krr'): ['ECFP', 1024],
    ('hopv', 'xgb_regression'): ['ECFP', 1024],
    ('hopv', 'graphconvreg'): ['GraphConv', 75],
    ('hopv', 'dag_regression'): ['GraphConv', 75],
    ('hopv', 'weave_regression'): ['Weave', 75],
    ('lipo', 'tf_regression'): ['ECFP', 1024],
    ('lipo', 'rf_regression'): ['ECFP', 1024],
    ('lipo', 'krr'): ['ECFP', 1024],
    ('lipo', 'xgb_regression'): ['ECFP', 1024],
    ('lipo', 'graphconvreg'): ['GraphConv', 75],
    ('lipo', 'dag_regression'): ['GraphConv', 75],
    ('lipo', 'weave_regression'): ['Weave', 75],
    ('nci', 'tf_regression'): ['ECFP', 1024],
    ('nci', 'rf_regression'): ['ECFP', 1024],
    ('nci', 'krr'): ['ECFP', 1024],
    ('nci', 'xgb_regression'): ['ECFP', 1024],
    ('nci', 'graphconvreg'): ['GraphConv', 75],
    ('nci', 'weave_regression'): ['Weave', 75],
    ('ppb', 'tf_regression'): ['ECFP', 1024],
    ('ppb', 'rf_regression'): ['ECFP', 1024],
    ('ppb', 'krr'): ['ECFP', 1024],
    ('ppb', 'xgb_regression'): ['ECFP', 1024],
    ('ppb', 'graphconvreg'): ['GraphConv', 75],
    ('ppb', 'dag_regression'): ['GraphConv', 75],
    ('ppb', 'weave_regression'): ['Weave', 75],
    ('sampl', 'tf_regression'): ['ECFP', 1024],
    ('sampl', 'rf_regression'): ['ECFP', 1024],
    ('sampl', 'krr'): ['ECFP', 1024],
    ('sampl', 'xgb_regression'): ['ECFP', 1024],
    ('sampl', 'graphconvreg'): ['GraphConv', 75],
    ('sampl', 'dag_regression'): ['GraphConv', 75],
    ('sampl', 'weave_regression'): ['Weave', 75],
    ('kaggle', 'tf_regression'): [None, 14293],
    ('kaggle', 'rf_regression'): [None, 14293],
    ('kaggle', 'krr'): [None, 14293],
    ('pdbbind', 'tf_regression'): ['grid', 2052],
    ('pdbbind', 'rf_regression'): ['grid', 2052],
    ('qm7', 'tf_regression'): ['ECFP', 1024],
    ('qm7', 'rf_regression'): ['ECFP', 1024],
    ('qm7', 'krr'): ['ECFP', 1024],
    ('qm7', 'graphconvreg'): ['GraphConv', 75],
    ('qm7', 'tf_regression_ft'): ['CoulombMatrix', [23, 23]],
    ('qm7', 'dtnn'): ['CoulombMatrix', [23, 23]],
    ('qm7', 'ani'): ['BPSymmetryFunction', [23, 4]],
    ('qm7b', 'tf_regression_ft'): ['CoulombMatrix', [23, 23]],
    ('qm7b', 'dtnn'): ['CoulombMatrix', [23, 23]],
    ('qm8', 'tf_regression'): ['ECFP', 1024],
    ('qm8', 'rf_regression'): ['ECFP', 1024],
    ('qm8', 'krr'): ['ECFP', 1024],
    ('qm8', 'graphconvreg'): ['GraphConv', 75],
    ('qm8', 'tf_regression_ft'): ['CoulombMatrix', [26, 26]],
    ('qm8', 'dtnn'): ['CoulombMatrix', [26, 26]],
    ('qm8', 'ani'): ['BPSymmetryFunction', [26, 4]],
    ('qm9', 'tf_regression'): ['ECFP', 1024],
    ('qm9', 'rf_regression'): ['ECFP', 1024],
    ('qm9', 'krr'): ['ECFP', 1024],
    ('qm9', 'graphconvreg'): ['GraphConv', 75],
    ('qm9', 'tf_regression_ft'): ['CoulombMatrix', [29, 29]],
    ('qm9', 'dtnn'): ['CoulombMatrix', [29, 29]]
    ('qm9', 'dtnn'): ['CoulombMatrix', [29, 29]],
    ('qm9', 'ani'): ['BPSymmetryFunction', [29, 4]]
}

CheckSplit = {
Loading