2aa5cccc7c65d14305e60e0a61781aa11cb7142d,deepchem/models/tensorgraph/layers.py,LSTM,create_tensor,#LSTM#Any#Any#,1169

Before Change


    if len(inputs) != 1:
      raise ValueError("Must have one parent")
    parent_tensor = inputs[0]
    if tfe.in_eager_mode():
      lstm_cell = self._cell
      zero_state = self._zero_state
    else:
      lstm_cell = tf.contrib.rnn.LSTMCell(self.n_hidden)
      zero_state = lstm_cell.zero_state(self.batch_size, tf.float32)
    if set_tensors:
      initial_state = tf.contrib.rnn.LSTMStateTuple(
          tf.placeholder(tf.float32, zero_state.c.get_shape()),
          tf.placeholder(tf.float32, zero_state.h.get_shape()))
    elif "initial_state" in kwargs:
      initial_state = kwargs["initial_state"]

After Change


      zero_state = self._zero_state
    else:
      lstm_cell = tf.keras.layers.LSTMCell(self.n_hidden)
      zero_state = [tf.zeros((self.batch_size, self.n_hidden), tf.float32)] * 2
    if set_tensors:
      initial_state = [
          tf.placeholder(tf.float32, zero_state[0].get_shape()),
          tf.placeholder(tf.float32, zero_state[1].get_shape())
      ]
    elif "initial_state" in kwargs:
      initial_state = kwargs["initial_state"]
    else:
      initial_state = zero_state
    if tf.executing_eagerly():
      out_tensor, final_state1, final_state2 = self._rnn(
          parent_tensor, initial_state=initial_state)
    else:
      with tf.variable_scope(self.name or "rnn"):
        out_tensor, final_state1, final_state2 = tf.keras.layers.RNN(
            lstm_cell, return_state=True, return_sequences=True)(
                parent_tensor, initial_state=initial_state)
    final_state = [final_state1, final_state2]
    if set_tensors:
      self._record_variable_scope(self.name)
      self.out_tensor = out_tensor
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 10

Instances


Project Name: deepchem/deepchem
Commit Name: 2aa5cccc7c65d14305e60e0a61781aa11cb7142d
Time: 2019-03-28
Author: peastman@stanford.edu
File Name: deepchem/models/tensorgraph/layers.py
Class Name: LSTM
Method Name: create_tensor


Project Name: deepchem/deepchem
Commit Name: 2aa5cccc7c65d14305e60e0a61781aa11cb7142d
Time: 2019-03-28
Author: peastman@stanford.edu
File Name: deepchem/models/tensorgraph/layers.py
Class Name: LSTM
Method Name: create_tensor


Project Name: deepchem/deepchem
Commit Name: 2aa5cccc7c65d14305e60e0a61781aa11cb7142d
Time: 2019-03-28
Author: peastman@stanford.edu
File Name: deepchem/models/tensorgraph/layers.py
Class Name: LSTM
Method Name: __init__


Project Name: deepchem/deepchem
Commit Name: 2aa5cccc7c65d14305e60e0a61781aa11cb7142d
Time: 2019-03-28
Author: peastman@stanford.edu
File Name: deepchem/models/tensorgraph/layers.py
Class Name: GRU
Method Name: __init__