Commit eb301f35 authored by Bharath Ramsundar's avatar Bharath Ramsundar
Browse files

Cleanup

parent da3a13ca
Loading
Loading
Loading
Loading
+2 −11
Original line number Diff line number Diff line
@@ -183,11 +183,6 @@ class Dataset(object):
    Returns minibatches from dataset.
    """
    for i, (X, y, w, ids) in enumerate(self.itershards()):
      ######################## DEBUG
      print("Dataset.iterbatches()")
      print("i, X.shape, y.shape")
      print(i, X.shape, y.shape)
      ######################## DEBUG
      nb_sample = np.shape(X)[0]
      if batch_size is None:
        shard_batch_size = nb_sample
@@ -403,17 +398,11 @@ def _df_to_numpy(df, feature_types, tasks):
      feature_list.append(datapoint[feature_type])
    try:
      features = np.squeeze(np.concatenate(feature_list))
      ################################# DEBUG
      #print("features.size: %s" % str(features.size))
      #print("features.size == 0")
      #print(features.size == 0)
      if features.size == 0:
        #print("CONTINUING")
        features = np.zeros(feature_shape)
        tensors.append(features)
        missing[ind, :] = 1
        continue
      ################################# DEBUG
      for feature_ind, val in enumerate(features):
        if features[feature_ind] == "":
          features[feature_ind] = 0.
@@ -441,6 +430,8 @@ def _df_to_numpy(df, feature_types, tasks):
        y[ind, task] = 0.
        w[ind, task] = 0.

  # Adding this assertion in to avoid ill-formed outputs.
  assert len(sorted_ids) == len(x) == len(y) == len(w)
  return sorted_ids, x.astype(float), y.astype(float), w.astype(float)

def compute_mean_and_std(df):
+0 −3
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ class TestDrop(TestAPI):
    verbosity = "high"
    len_full = 25

    ## This is for good debug (to make sure nasty state isn't being passed around)
    current_dir = os.path.dirname(os.path.realpath(__file__))
    feature_dir = os.path.join(self.base_dir, "features")
    samples_dir = os.path.join(self.base_dir, "samples")
@@ -54,8 +53,6 @@ class TestDrop(TestAPI):
    dataset = Dataset(data_dir=full_dir, samples=featurized_samples, 
                      featurizers=featurizers, tasks=emols_tasks,
                      verbosity=verbosity, reload=reload)
    print("len(dataset)")
    print(len(dataset))

    X, y, w, ids = dataset.to_numpy()
    print("ids.shape, X.shape, y.shape, w.shape")
+0 −8
Original line number Diff line number Diff line
@@ -257,14 +257,6 @@ class DataFeaturizer(object):
        if ind % self.log_every_n == 0:
          log("Featurizing sample %d" % ind, self.verbosity)
        mol = Chem.MolFromSmiles(smiles)
        ################################ DEBUG
        if mol is None:
          #print("RDKit loading failed at %s" % smiles)
          output = featurizer.featurize([mol], verbosity=self.verbosity)
          #print("featurizer returned %s" % str(output))
          #print("type(output)")
          #print(type(output))
        ################################ DEBUG
        features.append(featurizer.featurize([mol], verbosity=self.verbosity))
    else:
      def featurize_wrapper(smiles, dilled_featurizer):
+0 −14
Original line number Diff line number Diff line
@@ -137,29 +137,15 @@ class Model(object):
    """
    y_preds = []
    batch_size = self.model_params["batch_size"]
    ######################## DEBUG
    print("Model.predict()")
    print("len(dataset)")
    print(len(dataset))
    ######################## DEBUG
    for (X_batch, y_batch, w_batch, ids_batch) in dataset.iterbatches(batch_size):
      y_pred_batch = np.reshape(self.predict_on_batch(X_batch), y_batch.shape)
      y_pred_batch = undo_transforms(y_pred_batch, transformers)
      y_preds.append(y_pred_batch)
      ######################## DEBUG
      print("y_batch.shape, y_pred_batch.shape")
      print(y_batch.shape, y_pred_batch.shape)
      ######################## DEBUG
    y_pred = np.vstack(y_preds)
  
    # The iterbatches does padding with zero-weight examples on the last batch.
    # Remove padded examples.
    n_samples, n_tasks = len(dataset), len(self.tasks)
    ######################## DEBUG
    print("Model.predict()")
    print("y_pred.shape, n_samples, n_tasks")
    print(y_pred.shape, n_samples, n_tasks)
    ######################## DEBUG
    y_pred = np.reshape(y_pred, (n_samples, n_tasks))
    return y_pred