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

Now crashing at save step

parent 83f0cdd0
Loading
Loading
Loading
Loading
+1 −17
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ from keras.layers.core import Dense, Dropout, Activation
from keras.layers.normalization import BatchNormalization 
from keras.optimizers import SGD
from deepchem.models.keras_models import KerasModel
from deepchem.utils.evaluate import to_one_hot

class MultiTaskDNN(KerasModel):
  """
@@ -139,20 +140,3 @@ class SingleTaskDNN(MultiTaskDNN):
    super(SingleTaskDNN, self).__init__(task_types, model_params,
                                        initialize_raw_model=initialize_raw_model,
                                        verbosity=verbosity)

def to_one_hot(y):
  """Transforms label vector into one-hot encoding.

  Turns y into vector of shape [n_samples, 2] (assuming binary labels).

  y: np.ndarray
    A vector of shape [n_samples, 1]
  """
  n_samples = np.shape(y)[0]
  y_hot = np.zeros((n_samples, 2))
  for index, val in enumerate(y):
    if val == 0:
      y_hot[index] = np.array([1, 0])
    elif val == 1:
      y_hot[index] = np.array([0, 1])
  return y_hot
+2 −1
Original line number Diff line number Diff line
@@ -79,6 +79,7 @@ from tensorflow.python.platform import logging

from deepchem.models.tensorflow_models import TensorflowClassifier
from deepchem.models.tensorflow_models import model_ops
from deepchem.utils.evaluate import to_one_hot

class TensorflowMultiTaskClassifier(TensorflowClassifier):
  """Implements an icml model as configured in a model_config.proto."""
@@ -157,7 +158,7 @@ class TensorflowMultiTaskClassifier(TensorflowClassifier):
    feed_dict = {}
    feed_dict[self.mol_features] = X_b
    for task in xrange(self.num_tasks):
      feed_dict[self.labels[task]] = y_b[:, task]
      feed_dict[self.labels[task]] = to_one_hot(y_b[:, task])
      feed_dict[self.weights[task]] = w_b[:, task]
    return feed_dict

deepchem/utils/dataset.py

deleted100644 → 0
+0 −0

Empty file deleted.

+17 −0
Original line number Diff line number Diff line
@@ -20,6 +20,23 @@ __author__ = "Bharath Ramsundar"
__copyright__ = "Copyright 2015, Stanford University"
__license__ = "LGPL"

def to_one_hot(y):
  """Transforms label vector into one-hot encoding.

  Turns y into vector of shape [n_samples, 2] (assuming binary labels).

  y: np.ndarray
    A vector of shape [n_samples, 1]
  """
  n_samples = np.shape(y)[0]
  y_hot = np.zeros((n_samples, 2))
  for index, val in enumerate(y):
    if val == 0:
      y_hot[index] = np.array([1, 0])
    elif val == 1:
      y_hot[index] = np.array([0, 1])
  return y_hot

def threshold_predictions(y, threshold):
  y_out = np.zeros_like(y)
  for ind, pred in enumerate(y):