Exemple #1
0
    def log_outputs(outputs, batch, summarizer, global_step, prefix):
        preimage = masked_symbolic_state_index(batch['preimage'],
                                               batch['preimage_mask'])
        preimage_preds = outputs['preimage_preds'].argmax(-1)
        preimage_preds.masked_fill_(batch['preimage_loss_mask'] == 0, 2)
        preimage.masked_fill_(batch['preimage_loss_mask'] == 0, 2)

        preimage_acc, preimage_mask_acc = masked_binary_accuracy(
            tu.to_onehot(preimage_preds, 3), preimage)
        reachable_acc = classification_accuracy(outputs['reachable_preds'],
                                                batch['reachable'])
        satisfied_acc = classification_accuracy(
            outputs['satisfied_preds'], batch['satisfied'][:, -1].long())
        dependency_acc = classification_accuracy(
            outputs['dependency_preds'], batch['dependency'][:, -1].long())

        summarizer.add_scalar(prefix + 'acc/preimage',
                              preimage_acc,
                              global_step=global_step)
        summarizer.add_scalar(prefix + 'acc/preimage_mask',
                              preimage_mask_acc,
                              global_step=global_step)
        summarizer.add_scalar(prefix + 'acc/reachable',
                              reachable_acc,
                              global_step=global_step)
        summarizer.add_scalar(prefix + 'acc/satisfied',
                              satisfied_acc,
                              global_step=global_step)
        summarizer.add_scalar(prefix + 'acc/dependency',
                              dependency_acc,
                              global_step=global_step)
Exemple #2
0
    def log_outputs(outputs, batch, summarizer, global_step, prefix):
        preimage = masked_symbolic_state_index(batch['preimage'],
                                               batch['preimage_mask'])
        preimage_preds = outputs['preimage_preds'].argmax(-1)
        preimage_preds.masked_fill_(batch['preimage_loss_mask'] == 0, 2)
        preimage.masked_fill_(batch['preimage_loss_mask'] == 0, 2)

        preimage_acc, preimage_mask_acc = masked_binary_accuracy(
            tu.to_onehot(preimage_preds, 3), preimage)
        focus = masked_symbolic_state_index(batch['goal'], batch['focus_mask'])
        focus_preds = outputs['focus_preds'].argmax(-1)
        focus_acc, focus_mask_acc = masked_binary_accuracy(
            tu.to_onehot(focus_preds, 3), focus)
        reachable_acc = classification_accuracy(outputs['reachable_preds'],
                                                batch['reachable'])
        summarizer.add_scalar(prefix + 'acc/focus',
                              focus_acc,
                              global_step=global_step)
        summarizer.add_scalar(prefix + 'acc/focus_mask',
                              focus_mask_acc,
                              global_step=global_step)
        summarizer.add_scalar(prefix + 'acc/preimage',
                              preimage_acc,
                              global_step=global_step)
        summarizer.add_scalar(prefix + 'acc/preimage_mask',
                              preimage_mask_acc,
                              global_step=global_step)
        summarizer.add_scalar(prefix + 'acc/reachable',
                              reachable_acc,
                              global_step=global_step)
Exemple #3
0
 def log_outputs(outputs, batch, summarizer, global_step, prefix):
     subgoal = masked_symbolic_state_index(batch['subgoal'],
                                           batch['subgoal_mask'])
     subgoal_preds = outputs['subgoal_preds'].argmax(-1)
     subgoal_acc, subgoal_mask_acc = masked_binary_accuracy(
         tu.to_onehot(subgoal_preds, 3), subgoal)
     satisfied_acc = classification_accuracy(
         outputs['satisfied_preds'], batch['satisfied'][:, -1].long())
     dependency_acc = classification_accuracy(
         outputs['dependency_preds'], batch['dependency'][:, -1].long())
     summarizer.add_scalar(prefix + 'acc/subgoal',
                           subgoal_acc,
                           global_step=global_step)
     summarizer.add_scalar(prefix + 'acc/subgoal_mask',
                           subgoal_mask_acc,
                           global_step=global_step)
     summarizer.add_scalar(prefix + 'acc/satisfied',
                           satisfied_acc,
                           global_step=global_step)
     summarizer.add_scalar(prefix + 'acc/dependency',
                           dependency_acc,
                           global_step=global_step)