Commit 9d7d558b authored by Bharath Ramsundar's avatar Bharath Ramsundar
Browse files

Changes

parent 55e8eacf
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ class Sequential(Model):

  def __init__(self, name=None, logdir=None):
    self.layers = []  # stack of layers
    self.outputs = []  # tensors (length 1)
    self.outputs = None  # tensors (length 1)

    if not name:
      prefix = 'sequential_'
@@ -88,7 +88,7 @@ class Sequential(Model):
        # first layer in model: check that it is an input layer

      else:
        self.outputs = layer(self.outputs[0])
        self.outputs = layer(self.outputs)

      self.layers.append(layer)

@@ -101,7 +101,7 @@ class Sequential(Model):
      raise ValueError("First layer in sequential model must be InputLayer")
    with self.graph.as_default():
      self.features = layer()[0]
      self.outputs = [self.features]
      self.outputs = self.features
      self.layers = [layer]

  def add_labels(self, layer):
@@ -119,7 +119,7 @@ class Sequential(Model):
    # Add losses to graph
    with self.graph.as_default():
      # Loss for each batch element
      batch_loss = loss(self.outputs[0], self.labels)
      batch_loss = loss(self.outputs, self.labels)
      # Loss should be a float
      self.loss = tf.reduce_sum(batch_loss)

@@ -172,9 +172,9 @@ class Sequential(Model):
            if ind % log_every_N_batches == 0:
              print("On batch %d" % ind)
            feed_dict = {self.features: X_b, self.labels: y_b}
            fetches = self.outputs + [train_op, self.loss]
            fetches = [self.outputs] + [train_op, self.loss]
            fetched_values = sess.run(fetches, feed_dict=feed_dict)
            output = fetched_values[:len(self.outputs)]
            output = fetched_values[:1]
            loss = fetched_values[-1]
            avg_loss += loss
            y_pred = np.squeeze(np.array(output))
+0 −6
Original line number Diff line number Diff line
@@ -334,11 +334,7 @@ class Dense(Layer):
    output = model_ops.dot(x, self.W)
    if self.bias:
      output += self.b
    ################################################# DEBUG
    #outputs = to_list(self.activation(output))
    #return outputs
    return output
    ################################################# DEBUG


class Dropout(Layer):
@@ -467,13 +463,11 @@ class BatchNormalization(Layer):
        shape, initializer='one', name='{}_running_std'.format(self.name))

  def call(self, x):
    ###################################################### DEBUG
    if not isinstance(x, list):
      input_shape = model_ops.int_shape(x)
    else:
      x = x[0]
      input_shape = model_ops.int_shape(x)
    ###################################################### DEBUG
    self.build(input_shape)
    if self.mode == 0 or self.mode == 2:

+0 −31
Original line number Diff line number Diff line
@@ -562,18 +562,7 @@ class AttnLSTMEmbedding(Layer):
    x, xp = x_xp

    ## Initializes trainable weights.
    ######################################################### DEBUG
    #n_feat = xp_input_shape[1]
    #n_feat = xp.get_shape()[1]
    n_feat = self.n_feat
    ######################################################### DEBUG
    ######################################################### DEBUG
    print("AttnLSTMEmbedding")
    print("x")
    print(x)
    print("xp")
    print(xp)
    ######################################################### DEBUG

    self.lstm = LSTMStep(n_feat, 2 * n_feat)
    self.q_init = model_ops.zeros([self.n_test, n_feat])
@@ -702,9 +691,7 @@ class ResiLSTMEmbedding(Layer):
      Returns two tensors of same shape as input. Namely the output shape will
      be [(n_test, n_feat), (n_support, n_feat)]
    """
    ########################################################### DEBUG
    self.build()
    ########################################################### DEBUG
    x, xp = argument

    # Get initializations
@@ -795,10 +782,6 @@ class LSTMStep(Layer):

  #def build(self, input_shape):
  def build(self):
    #################################### DEBUG
    #x, _, _ = input_shape # Unpack
    #self.input_dim = x[1]
    #################################### DEBUG

    self.W = self.init((self.input_dim, 4 * self.output_dim))
    self.U = self.inner_init((self.output_dim, 4 * self.output_dim))
@@ -814,24 +797,10 @@ class LSTMStep(Layer):
    return [(x[0], self.output_dim), h_tm1, c_tm1]

  def call(self, x_states, mask=None):
    ############################################### DEBUG
    self.build()
    ############################################### DEBUG
    x, h_tm1, c_tm1 = x_states  # Unpack

    # Taken from Keras code [citation needed]
    ####################################################### DEBUG
    #print("x")
    #print(x)
    #print("self.W")
    #print(self.W)
    #print("h_tm1")
    #print(h_tm1)
    #print("self.U")
    #print(self.U)
    #print("self.b")
    #print(self.b)
    ####################################################### DEBUG
    z = model_ops.dot(x, self.W) + model_ops.dot(h_tm1, self.U) + self.b

    z0 = z[:, :self.output_dim]
+1 −1
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ K = 4
max_depth = 3
# num positive/negative ligands
n_pos = 1
n_neg = 5
n_neg = 1
# Set batch sizes for network
test_batch_size = 128
support_batch_size = n_pos + n_neg
+2 −2
Original line number Diff line number Diff line
@@ -17,8 +17,8 @@ K = 4
# Depth of attention module
max_depth = 3
# number positive/negative ligands
n_pos = 10
n_neg = 10
n_pos = 1
n_neg = 1
# Set batch sizes for network
test_batch_size = 128
support_batch_size = n_pos + n_neg
Loading