models_vd/model.py [245:267]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      for opt_id in range(num_options):
        option_batch['ans_in'] = batch['opt_in'][opt_id]
        option_batch['ans_out'] = batch['opt_out'][opt_id]
        option_batch['ans_len'] = batch['opt_len'][opt_id]

        feeder = self.decoder.produce_feed_dict(option_batch, output)
        scores = sess.run(phase_output, feed_dict=feeder)
        option_scores[:, opt_id] = scores

    # Part 3: Run the decoder model
    elif self.params['decoder'] == 'disc':
      batch_size = batch['opt_len'][0].shape[0]
      feeder = self.decoder.produce_feed_dict(batch, output)
      output.update(sess.run(self.outputs['generate_answer'], feeder))
      option_scores = output['scores']

    # extract ground truth score, and get ranks
    gt_scores = option_scores[(range(batch_size), batch['gt_ind'])]
    ranks = np.sum(option_scores > gt_scores.reshape(-1, 1), axis=1) + 1

    output['scores'] = option_scores

    return ranks, output
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



models_vd/model.py [296:317]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      for opt_id in range(num_options):
        option_batch['ans_in'] = batch['opt_in'][opt_id]
        option_batch['ans_out'] = batch['opt_out'][opt_id]
        option_batch['ans_len'] = batch['opt_len'][opt_id]

        feeder = self.decoder.produce_feed_dict(option_batch, output)
        scores = sess.run(phase_output, feed_dict=feeder)
        option_scores[:, opt_id] = scores

    # Part 3: Run the decoder model
    elif self.params['decoder'] == 'disc':
      batch_size = batch['opt_len'][0].shape[0]
      feeder = self.decoder.produce_feed_dict(batch, output)
      output.update(sess.run(self.outputs['generate_answer'], feeder))
      option_scores = output['scores']

    # extract ground truth score, and get ranks
    gt_scores = option_scores[(range(batch_size), batch['gt_ind'])]
    ranks = np.sum(option_scores > gt_scores.reshape(-1, 1), axis=1) + 1

    output['scores'] = option_scores
    return ranks, output
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



