コード例 #1
0
def add_default_summaries(mode, arop_full_summary_iters, summarize_ops,
                          summarize_names, to_aggregate, action_prob_op,
                          input_tensors, scope_name):
    assert(mode == 'train_bkp' or mode == 'val' or mode == 'test'), \
      'add_default_summaries mode is neither train_bkp or val or test.'

    s_ops = tf_utils.get_default_summary_ops()

    if mode == 'train_bkp':
        s_ops.summary_ops, s_ops.print_summary_ops, additional_return_ops, \
        arop_summary_iters, arop_eval_fns = tf_utils.simple_summaries(
                summarize_ops, summarize_names, mode, to_aggregate=False,
                scope_name=scope_name)
        s_ops.additional_return_ops += additional_return_ops
        s_ops.arop_summary_iters += arop_summary_iters
        s_ops.arop_eval_fns += arop_eval_fns
    elif mode == 'val':
        s_ops.summary_ops, s_ops.print_summary_ops, additional_return_ops, \
        arop_summary_iters, arop_eval_fns = tf_utils.simple_summaries(
                summarize_ops, summarize_names, mode, to_aggregate=to_aggregate,
                scope_name=scope_name)
        s_ops.additional_return_ops += additional_return_ops
        s_ops.arop_summary_iters += arop_summary_iters
        s_ops.arop_eval_fns += arop_eval_fns

    elif mode == 'test':
        s_ops.summary_ops, s_ops.print_summary_ops, additional_return_ops, \
        arop_summary_iters, arop_eval_fns = tf_utils.simple_summaries(
            [], [], mode, to_aggregate=[], scope_name=scope_name)
        s_ops.additional_return_ops += additional_return_ops
        s_ops.arop_summary_iters += arop_summary_iters
        s_ops.arop_eval_fns += arop_eval_fns

    if mode == 'val':
        arop = s_ops.additional_return_ops
        arop += [[action_prob_op, input_tensors['train_bkp']['action']]]
        arop += [[
            input_tensors['step']['loc_on_map'],
            input_tensors['common']['goal_loc'],
            input_tensors['step']['gt_dist_to_goal']
        ]]
        arop += [[
            input_tensors['step']['loc_on_map'],
            input_tensors['common']['orig_maps'],
            input_tensors['common']['goal_loc']
        ]]
        s_ops.arop_summary_iters += [
            -1, arop_full_summary_iters, arop_full_summary_iters
        ]
        s_ops.arop_eval_fns += [eval_ap, eval_dist, plot_trajectories]

    elif mode == 'test':
        arop = s_ops.additional_return_ops
        arop += [[
            input_tensors['step']['loc_on_map'],
            input_tensors['common']['goal_loc'],
            input_tensors['step']['gt_dist_to_goal']
        ]]
        arop += [[input_tensors['step']['gt_dist_to_goal']]]
        arop += [[
            input_tensors['step']['loc_on_map'],
            input_tensors['common']['goal_loc'],
            input_tensors['step']['gt_dist_to_goal'],
            input_tensors['step']['node_ids'],
            input_tensors['step']['perturbs']
        ]]
        arop += [[
            input_tensors['step']['loc_on_map'],
            input_tensors['common']['orig_maps'],
            input_tensors['common']['goal_loc']
        ]]
        s_ops.arop_summary_iters += [-1, -1, -1, arop_full_summary_iters]
        s_ops.arop_eval_fns += [
            eval_dist, save_d_at_t, save_all, plot_trajectories
        ]
    return s_ops
コード例 #2
0
ファイル: nav_utils.py プロジェクト: 812864539/models
def add_default_summaries(mode, arop_full_summary_iters, summarize_ops,
                          summarize_names, to_aggregate, action_prob_op,
                          input_tensors, scope_name):
  assert(mode == 'train' or mode == 'val' or mode == 'test'), \
    'add_default_summaries mode is neither train or val or test.'
  
  s_ops = tf_utils.get_default_summary_ops()
  
  if mode == 'train':
    s_ops.summary_ops, s_ops.print_summary_ops, additional_return_ops, \
    arop_summary_iters, arop_eval_fns = tf_utils.simple_summaries(
            summarize_ops, summarize_names, mode, to_aggregate=False,
            scope_name=scope_name)
    s_ops.additional_return_ops += additional_return_ops
    s_ops.arop_summary_iters += arop_summary_iters
    s_ops.arop_eval_fns += arop_eval_fns
  elif mode == 'val':
    s_ops.summary_ops, s_ops.print_summary_ops, additional_return_ops, \
    arop_summary_iters, arop_eval_fns = tf_utils.simple_summaries(
            summarize_ops, summarize_names, mode, to_aggregate=to_aggregate,
            scope_name=scope_name)
    s_ops.additional_return_ops += additional_return_ops
    s_ops.arop_summary_iters += arop_summary_iters
    s_ops.arop_eval_fns += arop_eval_fns
  
  elif mode == 'test':
    s_ops.summary_ops, s_ops.print_summary_ops, additional_return_ops, \
    arop_summary_iters, arop_eval_fns = tf_utils.simple_summaries(
        [], [], mode, to_aggregate=[], scope_name=scope_name)
    s_ops.additional_return_ops += additional_return_ops
    s_ops.arop_summary_iters += arop_summary_iters
    s_ops.arop_eval_fns += arop_eval_fns

  
  if mode == 'val':
    arop = s_ops.additional_return_ops
    arop += [[action_prob_op, input_tensors['train']['action']]]
    arop += [[input_tensors['step']['loc_on_map'],
              input_tensors['common']['goal_loc'],
              input_tensors['step']['gt_dist_to_goal']]]
    arop += [[input_tensors['step']['loc_on_map'],
              input_tensors['common']['orig_maps'],
              input_tensors['common']['goal_loc']]]
    s_ops.arop_summary_iters += [-1, arop_full_summary_iters,
                                 arop_full_summary_iters]
    s_ops.arop_eval_fns += [eval_ap, eval_dist, plot_trajectories]
  
  elif mode == 'test':
    arop = s_ops.additional_return_ops
    arop += [[input_tensors['step']['loc_on_map'],
              input_tensors['common']['goal_loc'],
              input_tensors['step']['gt_dist_to_goal']]]
    arop += [[input_tensors['step']['gt_dist_to_goal']]]
    arop += [[input_tensors['step']['loc_on_map'],
              input_tensors['common']['goal_loc'],
              input_tensors['step']['gt_dist_to_goal'],
              input_tensors['step']['node_ids'],
              input_tensors['step']['perturbs']]]
    arop += [[input_tensors['step']['loc_on_map'],
              input_tensors['common']['orig_maps'],
              input_tensors['common']['goal_loc']]]
    s_ops.arop_summary_iters += [-1, -1, -1, arop_full_summary_iters]
    s_ops.arop_eval_fns += [eval_dist, save_d_at_t, save_all,
                            plot_trajectories]
  return s_ops