(self, x, sequence_length)
return all_outputs, all_summaries
Performs the DNC calculation for all time steps of the input data (x).
        Uses tf.while_loop as a main way of doing that. Tf.while_loop requires explicit passing of the parameters which 
        change from step to step so it messes up the beauty of the code a little bit.

        :param x: input data of shape [batch_size, input_size, sequence_length]
        :param sequence_length:
        :return: output of the same shape as x and summaries which are to be passed to notify() method
Performs the DNC calculation for all time steps of the input data (x).
        Uses tf.while_loop as a main way of doing that. Tf.while_loop requires explicit passing of the parameters which 
        change from step to step so it messes up the beauty of the code a little bit.
Performs the DNC calculation for all time steps of the input data ( x ) . Uses tf . while_loop as a main way of doing that . Tf . while_loop requires explicit passing of the parameters which change from step to step so it messes up the beauty of the code a little bit .
def __call__(self, x, sequence_length):
        """
        Performs the DNC calculation for all time steps of the input data (x).
        Uses tf.while_loop as a main way of doing that. Tf.while_loop requires explicit passing of the parameters which 
        change from step to step so it messes up the beauty of the code a little bit.

        :param x: input data of shape [batch_size, input_size, sequence_length]
        :param sequence_length:
        :return: output of the same shape as x and summaries which are to be passed to notify() method
        """
        # TODO is it possible to extend tensorflow's RNN and then use tf.nn.dynamic_rnn here?

        # dynamic shapes, batch size and sequence length
        # ideally, both would be dynamic, but tf throws an error because tf.unstack() (method used in DNC memory)
        # doesn't really work with dynamic shapes

        batch_size = self.batch_size
        # batch_size = tf.shape(x)[0]
        seq_len = tf.shape(x)[1]

        with tf.variable_scope("DNC"):
            condition = lambda step, *_: step < seq_len

            initial_state = [self.controller.initial_state(batch_size), self.memory.init_memory(batch_size)]
            output_initial = tf.zeros((batch_size, self.out_vector_size))

            all_outputs = tf.TensorArray(tf.float32, seq_len)
            # TODO remove the magic number
            all_summaries = [tf.TensorArray(tf.float32, seq_len)
                             for _ in range(len(initial_state[1]) + 13)]

            step, x, output, state, all_outputs, all_summaries = tf.while_loop(condition,
                                                                               self.while_loop_step,
                                                                               loop_vars=[0,
                                                                                          x,
                                                                                          output_initial,
                                                                                          initial_state,
                                                                                          all_outputs,
                                                                                          all_summaries],
                                                                               swap_memory=True)
        all_outputs = tf.transpose(all_outputs.stack(), [1, 0, 2])
        all_summaries = [summary.stack() for summary in all_summaries]
        return all_outputs, all_summaries
def __call__ ( self , x , sequence_length ) : # TODO is it possible to extend tensorflow's RNN and then use tf.nn.dynamic_rnn here? # dynamic shapes, batch size and sequence length # ideally, both would be dynamic, but tf throws an error because tf.unstack() (method used in DNC memory) # doesn't really work with dynamic shapes batch_size = self . batch_size # batch_size = tf.shape(x)[0] seq_len = tf . shape ( x ) [ 1 ] with tf . variable_scope ( "DNC" ) : condition = lambda step , * _ : step < seq_len initial_state = [ self . controller . initial_state ( batch_size ) , self . memory . init_memory ( batch_size ) ] output_initial = tf . zeros ( ( batch_size , self . out_vector_size ) ) all_outputs = tf . TensorArray ( tf . float32 , seq_len ) # TODO remove the magic number all_summaries = [ tf . TensorArray ( tf . float32 , seq_len ) for _ in range ( len ( initial_state [ 1 ] ) + 13 ) ] step , x , output , state , all_outputs , all_summaries = tf . while_loop ( condition , self . while_loop_step , loop_vars = [ 0 , x , output_initial , initial_state , all_outputs , all_summaries ] , swap_memory = True ) all_outputs = tf . transpose ( all_outputs . stack ( ) , [ 1 , 0 , 2 ] ) all_summaries = [ summary . stack ( ) for summary in all_summaries ] return all_outputs , all_summaries