Commit 4c1c2bb8 authored by Bharath Ramsundar's avatar Bharath Ramsundar Committed by GitHub
Browse files

Merge pull request #356 from joegomes/tf12

Update TensorflowModel classes to TF 0.12
parents 9577759e 1d2e3f52
Loading
Loading
Loading
Loading
+1 −7
Original line number Diff line number Diff line
@@ -23,14 +23,8 @@ install:
- pip install keras
- export KERAS_BACKEND=tensorflow
- conda install -c omnia mdtraj
- pip install tensorflow
- python setup.py install
#- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.12.0rc1-cp27-none-linux_x86_64.whl;
#  -O else export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.12.0rc1-cp35-cp35m-linux_x86_64.whl;
#  -O fi 
#- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then pip install --ignore-installed --upgrade $TF_BINARY_URL;
#  -O else pip3 install --ignore-installed --upgrade $TF_BINARY_URL;
#  -O fi
- conda install -c https://conda.anaconda.org/jjhelmus tensorflow=0.10.0rc0
script:
- nosetests -v deepchem --nologcapture
after_success:
+3 −3
Original line number Diff line number Diff line
@@ -301,7 +301,7 @@ class TensorflowGraphModel(Model):
      train_op = self.get_training_op(
          self.train_graph.graph, self.train_graph.loss)
      with self._get_shared_session(train=True) as sess:
        sess.run(tf.initialize_all_variables())
        sess.run(tf.global_variables_initializer())
        saver = tf.train.Saver(max_to_keep=max_checkpoints_to_keep)
        # Save an initial checkpoint.
        saver.save(sess, self._save_path, global_step=0)
@@ -461,10 +461,10 @@ class TensorflowGraphModel(Model):
      # self._save_path is "logdir/model.ckpt"
      if os.path.basename(self._save_path) in filename:
        try:
          N = int(filename.split("-")[-1])
          N = int(filename.split("-")[1].split(".")[0])
          if N > highest_num:
            highest_num = N
            last_checkpoint = filename
            last_checkpoint = "model.ckpt-"+str(N)
        except ValueError:
          pass
    return os.path.join(self.logdir, last_checkpoint)
+6 −6
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ def add_bias(tensor, init=None, name=None):
  """
  if init is None:
    init = tf.zeros([tensor.get_shape()[-1].value])
  with tf.op_scope([tensor], name, tensor.op.name):
  with tf.name_scope(name, tensor.op.name, [tensor]):
    b = tf.Variable(init, name='b')
    return tf.nn.bias_add(tensor, b)

@@ -156,7 +156,7 @@ def fully_connected_layer(tensor, size=None, weight_init=None, bias_init=None,
  if bias_init is None:
    bias_init = tf.zeros([size])

  with tf.op_scope([tensor], name, 'fully_connected'):
  with tf.name_scope(name, 'fully_connected', [tensor]):
    w = tf.Variable(weight_init, name='w', dtype=tf.float32)
    b = tf.Variable(bias_init, name='b', dtype=tf.float32)
    return tf.nn.xw_plus_b(tensor, w, b)
@@ -211,8 +211,8 @@ def multitask_logits(features, num_tasks, num_classes=2, weight_init=None,
  logits_list = []
  with tf.name_scope('multitask_logits'):
    for task_idx in range(num_tasks):
      with tf.op_scope([features], name,
                       ('task' + str(task_idx).zfill(len(str(num_tasks))))):
      with tf.name_scope(name,
                       ('task' + str(task_idx).zfill(len(str(num_tasks)))), [features]):
        logits_list.append(
            logits(features, num_classes, weight_init=weight_init,
                   bias_init=bias_init, dropout_prob=dropout_prob))
@@ -238,7 +238,7 @@ def logits(features, num_classes=2, weight_init=None, bias_init=None,
  Returns:
    A logits tensor with shape batch_size x num_classes.
  """
  with tf.op_scope([features], name, 'logits') as name:
  with tf.name_scope(name, 'logits', [features]) as name:
    return dropout(
        fully_connected_layer(features, num_classes, weight_init=weight_init,
                              bias_init=bias_init, name=name),
@@ -255,7 +255,7 @@ def softmax_N(tensor, name=None):
  Returns:
    A tensor with softmax-normalized values on the last dimension.
  """
  with tf.op_scope([tensor], name, 'softmax_N'):
  with tf.name_scope(name, 'softmax_N', [tensor]):
    exp_tensor = tf.exp(tensor)
    reduction_indices = [tensor.get_shape().ndims - 1]
    return tf.div(exp_tensor,
+1 −1
Original line number Diff line number Diff line
@@ -230,7 +230,7 @@ class ProgressiveJointRegressor(TensorflowMultiTaskRegressor):
      train_op = self.get_training_op(
          self.train_graph.graph, self.train_graph.loss)
      with self._get_shared_session(train=True) as sess:
        sess.run(tf.initialize_all_variables())
        sess.run(tf.global_variables_initializer())
        saver = tf.train.Saver(max_to_keep=max_checkpoints_to_keep)
        # Save an initial checkpoint.
        saver.save(sess, self._save_path, global_step=0)