code: # Delta Recurrent Neural Network (Delta-RNN) Framework
  #
  # This gives an implementation of the Delta-RNN framework given in Ororbia et al. 2017, arXiv:1703.08864 [cs.CL], 
  # https://arxiv.org/abs/1703.08864 using Python and Tensorflow.
  #
  # This code implements a variety of RNN models using the Delta-RNN Framework
  #
  # Stuart Hagler, 2017
  
  # Imports
  import tensorflow as tf
  
  # Local imports
  from delta_rnn import delta_rnn_graph
  
  # Define derived SCRN TensorFlow graph class
  class scrn_graph(delta_rnn_graph):
      
      # Graph constructor
      def __init__(self, num_gpus, alpha, c_size, h_size, vocabulary_size, num_training_unfoldings, 
                   num_validation_unfoldings, training_batch_size, validation_batch_size, optimization_frequency):
      
          # Input hyperparameters
          self._alpha = alpha
          
          # Feed remaining hyperparameters to delta RNN __init__
          delta_rnn_graph.__init__(self, num_gpus, c_size, h_size, vocabulary_size, num_training_unfoldings,
                                   num_validation_unfoldings, training_batch_size, validation_batch_size, 
                                   optimization_frequency)
          
      # SCRN cell definition
      def _cell(self, x, c, h):
          with tf.name_scope('h'):
              h = tf.sigmoid(tf.matmul(c, self._P) + tf.matmul(x, self._A) + tf.matmul(h, self._R))
          with tf.name_scope('c'):
              c = (1 - self._alpha) * tf.matmul(x, self._B) + self._alpha * c
          with tf.name_scope('o'):
              o = tf.matmul(h, self._U) + tf.matmul(c, self._V) 
          return o, c, h
      
      # Setup SCRN cell parameters
      def _setup_cell_parameters(self):
          with tf.name_scope('B'):
              self._B = tf.Variable(tf.truncated_normal([self._vocabulary_size, self._c_size], -0.1, 0.1))
          with tf.name_scope('A'):
              self._A = tf.Variable(tf.truncated_normal([self._vocabulary_size, self._h_size], -0.1, 0.1))
          with tf.name_scope('P'):
              self._P = tf.Variable(tf.truncated_normal([self._c_size, self._h_size], -0.1, 0.1))
          with tf.name_scope('R'):
              self._R = tf.Variable(tf.truncated_normal([self._h_size, self._h_size], -0.1, 0.1))
          with tf.name_scope('U'):
              self._U = tf.Variable(tf.truncated_normal([self._h_size, self._vocabulary_size], -0.1, 0.1))
          with tf.name_scope('V'):
              self._V = tf.Variable(tf.truncated_normal([self._c_size, self._vocabulary_size], -0.1, 0.1))
apis: tensorflow.matmul tensorflow.truncated_normal tensorflow.name_scope
api_extract: [(27, 'delta_rnn.delta_rnn_graph.__init__', 'delta_rnn_graph.__init__', (['self', 'num_gpus', 'c_size', 'h_size', 'vocabulary_size', 'num_training_unfoldings', 'num_validation_unfoldings', 'training_batch_size', 'validation_batch_size', 'optimization_frequency'], {}), False, 'from delta_rnn import delta_rnn_graph\n'), (33, 'tensorflow.name_scope', 'tf.name_scope', (['"""h"""'], {}), True, 'import tensorflow as tf\n'), (35, 'tensorflow.name_scope', 'tf.name_scope', (['"""c"""'], {}), True, 'import tensorflow as tf\n'), (37, 'tensorflow.name_scope', 'tf.name_scope', (['"""o"""'], {}), True, 'import tensorflow as tf\n'), (43, 'tensorflow.name_scope', 'tf.name_scope', (['"""B"""'], {}), True, 'import tensorflow as tf\n'), (45, 'tensorflow.name_scope', 'tf.name_scope', (['"""A"""'], {}), True, 'import tensorflow as tf\n'), (47, 'tensorflow.name_scope', 'tf.name_scope', (['"""P"""'], {}), True, 'import tensorflow as tf\n'), (49, 'tensorflow.name_scope', 'tf.name_scope', (['"""R"""'], {}), True, 'import tensorflow as tf\n'), (51, 'tensorflow.name_scope', 'tf.name_scope', (['"""U"""'], {}), True, 'import tensorflow as tf\n'), (53, 'tensorflow.name_scope', 'tf.name_scope', (['"""V"""'], {}), True, 'import tensorflow as tf\n'), (38, 'tensorflow.matmul', 'tf.matmul', (['h', 'self._U'], {}), True, 'import tensorflow as tf\n'), (38, 'tensorflow.matmul', 'tf.matmul', (['c', 'self._V'], {}), True, 'import tensorflow as tf\n'), (44, 'tensorflow.truncated_normal', 'tf.truncated_normal', (['[self._vocabulary_size, self._c_size]', '(-0.1)', '(0.1)'], {}), True, 'import tensorflow as tf\n'), (46, 'tensorflow.truncated_normal', 'tf.truncated_normal', (['[self._vocabulary_size, self._h_size]', '(-0.1)', '(0.1)'], {}), True, 'import tensorflow as tf\n'), (48, 'tensorflow.truncated_normal', 'tf.truncated_normal', (['[self._c_size, self._h_size]', '(-0.1)', '(0.1)'], {}), True, 'import tensorflow as tf\n'), (50, 'tensorflow.truncated_normal', 'tf.truncated_normal', (['[self._h_size, self._h_size]', '(-0.1)', '(0.1)'], {}), True, 'import tensorflow as tf\n'), (52, 'tensorflow.truncated_normal', 'tf.truncated_normal', (['[self._h_size, self._vocabulary_size]', '(-0.1)', '(0.1)'], {}), True, 'import tensorflow as tf\n'), (54, 'tensorflow.truncated_normal', 'tf.truncated_normal', (['[self._c_size, self._vocabulary_size]', '(-0.1)', '(0.1)'], {}), True, 'import tensorflow as tf\n'), (34, 'tensorflow.matmul', 'tf.matmul', (['h', 'self._R'], {}), True, 'import tensorflow as tf\n'), (36, 'tensorflow.matmul', 'tf.matmul', (['x', 'self._B'], {}), True, 'import tensorflow as tf\n'), (34, 'tensorflow.matmul', 'tf.matmul', (['c', 'self._P'], {}), True, 'import tensorflow as tf\n'), (34, 'tensorflow.matmul', 'tf.matmul', (['x', 'self._A'], {}), True, 'import tensorflow as tf\n')]