Commit fd0766bd authored by miaecle's avatar miaecle
Browse files

yapf

parent 6f2b005d
Loading
Loading
Loading
Loading
+17 −22
Original line number Diff line number Diff line
@@ -12,15 +12,13 @@ from deepchem.models.tensorgraph.layers import Layer, SigmoidCrossEntropy, \
from deepchem.models.tensorgraph.layers import convert_to_layers
from deepchem.trans import undo_transforms


class IRVLayer(Layer):
  """ Core layer of IRV classifier, architecture described in:
       https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2750043/
  """

  def __init__(self,
               n_tasks,
               K,
               **kwargs):
  def __init__(self, n_tasks, K, **kwargs):
    """
    Parameters
    ----------
@@ -79,14 +77,13 @@ class IRVLayer(Layer):
  def set_tensors(self, tensor):
    self.V, self.W, self.b, self.b2, self.out_tensor, self.trainable_weights, self.variables = tensor


class IRVRegularize(Layer):
  """ This Layer extracts the trainable weights in IRVLayer
  and return the their L2-norm
  """
  def __init__(self,
               IRVLayer,
               penalty=0.0,
               **kwargs):

  def __init__(self, IRVLayer, penalty=0.0, **kwargs):
    self.IRVLayer = IRVLayer
    self.penalty = penalty
    super(IRVRegularize, self).__init__(**kwargs)
@@ -101,14 +98,12 @@ class IRVRegularize(Layer):
      self.out_tensor = out_tensor
    return out_tensor


class Slice(Layer):
  """ Choose a slice of input given axis and order
  """

  def __init__(self,
               slice_num,
               axis=1,
               **kwargs):
  def __init__(self, slice_num, axis=1, **kwargs):
    """
    Parameters
    ----------
@@ -135,6 +130,7 @@ class Slice(Layer):
      self.out_tensor = out_tensor
    return out_tensor


class TensorflowMultiTaskIRVClassifier(TensorGraph):

  def __init__(self,
@@ -163,7 +159,6 @@ class TensorflowMultiTaskIRVClassifier(TensorGraph):
    super(TensorflowMultiTaskIRVClassifier, self).__init__(**kwargs)
    self.build_graph()


  def build_graph(self):
    """Constructs the graph architecture of IRV as described in:
       
+6 −2
Original line number Diff line number Diff line
@@ -1183,6 +1183,7 @@ class SoftMax(Layer):
      self.out_tensor = out_tensor
    return out_tensor


class Sigmoid(Layer):

  def __init__(self, in_layers=None, **kwargs):
@@ -1202,6 +1203,7 @@ class Sigmoid(Layer):
      self.out_tensor = out_tensor
    return out_tensor


class Concat(Layer):

  def __init__(self, in_layers=None, axis=1, **kwargs):
@@ -1548,6 +1550,7 @@ class SoftMaxCrossEntropy(Layer):
      self.out_tensor = out_tensor
    return out_tensor


class SigmoidCrossEntropy(Layer):

  def __init__(self, in_layers=None, **kwargs):
@@ -1568,6 +1571,7 @@ class SigmoidCrossEntropy(Layer):
      self.out_tensor = out_tensor
    return out_tensor


class ReduceMean(Layer):

  def __init__(self, in_layers=None, axis=None, **kwargs):
+4 −2
Original line number Diff line number Diff line
@@ -151,8 +151,10 @@ def benchmark_classification(train_dataset,
    # Building scikit logistic regression model
    def model_builder(model_dir_logreg):
      sklearn_model = LogisticRegression(
          penalty=penalty_type, C=1./penalty, 
          class_weight="balanced", n_jobs=-1)
          penalty=penalty_type,
          C=1. / penalty,
          class_weight="balanced",
          n_jobs=-1)
      return deepchem.models.sklearn_models.SklearnModel(
          sklearn_model, model_dir_logreg)