code/char_model.py
def run_train_iter(self, session, batch, summary_writer):
        """
        This performs a single training iteration (forward pass, loss computation, backprop, parameter update)

        Inputs:
          session: TensorFlow session
          batch: a Batch object
          summary_writer: for Tensorboard

        Returns:
          loss: The loss (averaged across the batch) for this batch.
          global_step: The current number of training iterations we've done
          param_norm: Global norm of the parameters
          gradient_norm: Global norm of the gradients
        """
        # Match up our input data with the placeholders
        input_feed = {}
        input_feed[self.context_ids] = batch.context_ids
        input_feed[self.context_mask] = batch.context_mask
        input_feed[self.qn_ids] = batch.qn_ids
        input_feed[self.qn_mask] = batch.qn_mask
        input_feed[self.ans_span] = batch.ans_span
        input_feed[self.keep_prob] = 1.0 - self.FLAGS.dropout  # apply dropout

        add_chars_to_feed(input_feed, self.context_char_ids, self.qn_char_ids, batch, self.id2word, self.char2id, self.FLAGS.char_limit)

        # output_feed contains the things we want to fetch.
        output_feed = [self.updates, self.summaries, self.loss, self.global_step, self.param_norm, self.gradient_norm]

        # Run the model
        [_, summaries, loss, global_step, param_norm, gradient_norm] = session.run(output_feed, input_feed)

        # All summaries in the graph are added to Tensorboard
        summary_writer.add_summary(summaries, global_step)

        return loss, global_step, param_norm, gradient_norm

        This performs a single training iteration (forward pass, loss computation, backprop, parameter update)

        Inputs:
          session: TensorFlow session
          batch: a Batch object
          summary_writer: for Tensorboard

        Returns:
          loss: The loss (averaged across the batch) for this batch.
          global_step: The current number of training iterations we've done
          param_norm: Global norm of the parameters
          gradient_norm: Global norm of the gradients
        
This performs a single training iteration (forward pass, loss computation, backprop, parameter update)
Inputs:
session: TensorFlow session
batch: a Batch object
summary_writer: for Tensorboard
This performs a single training iteration ( forward pass loss computation backprop parameter update ) Inputs : session : TensorFlow session batch : a Batch object summary_writer : for Tensorboard
def run_train_iter(self, session, batch, summary_writer):
        input_feed = {}
        input_feed[self.context_ids] = batch.context_ids
        input_feed[self.context_mask] = batch.context_mask
        input_feed[self.qn_ids] = batch.qn_ids
        input_feed[self.qn_mask] = batch.qn_mask
        input_feed[self.ans_span] = batch.ans_span
        input_feed[self.keep_prob] = 1.0 - self.FLAGS.dropout  
        add_chars_to_feed(input_feed, self.context_char_ids, self.qn_char_ids, batch, self.id2word, self.char2id, self.FLAGS.char_limit)
        output_feed = [self.updates, self.summaries, self.loss, self.global_step, self.param_norm, self.gradient_norm]
        [_, summaries, loss, global_step, param_norm, gradient_norm] = session.run(output_feed, input_feed)
        summary_writer.add_summary(summaries, global_step)
        return loss, global_step, param_norm, gradient_norm
def run_train_iter ( self , session , batch , summary_writer ) : input_feed = { } input_feed [ self . context_ids ] = batch . context_ids input_feed [ self . context_mask ] = batch . context_mask input_feed [ self . qn_ids ] = batch . qn_ids input_feed [ self . qn_mask ] = batch . qn_mask input_feed [ self . ans_span ] = batch . ans_span input_feed [ self . keep_prob ] = 1.0 - self . FLAGS . dropout add_chars_to_feed ( input_feed , self . context_char_ids , self . qn_char_ids , batch , self . id2word , self . char2id , self . FLAGS . char_limit ) output_feed = [ self . updates , self . summaries , self . loss , self . global_step , self . param_norm , self . gradient_norm ] [ _ , summaries , loss , global_step , param_norm , gradient_norm ] = session . run ( output_feed , input_feed ) summary_writer . add_summary ( summaries , global_step ) return loss , global_step , param_norm , gradient_norm
This performs a single training iteration (forward pass, loss computation, backprop, parameter update)
Inputs:
session: TensorFlow session
batch: a Batch object
summary_writer: for Tensorboard
This performs a single training iteration ( forward pass loss computation backprop parameter update ) Inputs : session : TensorFlow session batch : a Batch object summary_writer : for Tensorboard
"""
        This performs a single training iteration (forward pass, loss computation, backprop, parameter update)

        Inputs:
          session: TensorFlow session
          batch: a Batch object
          summary_writer: for Tensorboard

        Returns:
          loss: The loss (averaged across the batch) for this batch.
          global_step: The current number of training iterations we've done
          param_norm: Global norm of the parameters
          gradient_norm: Global norm of the gradients
        """ # Match up our input data with the placeholders # apply dropout # output_feed contains the things we want to fetch. # Run the model # All summaries in the graph are added to Tensorboard
The loss (averaged across the batch) for this batch.
global_step: The current number of training iterations we've done
param_norm: Global norm of the parameters
gradient_norm: Global norm of the gradients
The loss ( averaged across the batch ) for this batch . global_step : The current number of training iterations we ' ve done param_norm : Global norm of the parameters gradient_norm : Global norm of the gradients
loss
self
session
batch
summary_writer