Beispiel #1
0
    parser.add_argument('--device', choices=['gpu', 'cpu'])
    parser.add_argument('-c',
                        '--config',
                        metavar='C',
                        default=None,
                        help='The Configuration file')

    args = parser.parse_args()

    update_cfg_from_cfg(search_cfg, cfg)
    if args.config is not None:
        merge_cfg_from_file(args.config, cfg)
    config = cfg

    args.save = os.path.join(args.save, 'output')
    utils.create_exp_dir(args.save)

    args.input_size = eval(args.input_size)
    if len(args.input_size) != 4:
        raise ValueError('The batch size should be specified.')

    log_format = '%(asctime)s %(message)s'
    logging.basicConfig(stream=sys.stdout,
                        level=logging.INFO,
                        format=log_format,
                        datefmt='%m/%d %I:%M:%S %p')
    fh = logging.FileHandler(os.path.join(args.save, 'log.txt'))
    fh.setFormatter(logging.Formatter(log_format))
    logging.getLogger().addHandler(fh)

    if not torch.cuda.is_available():
Beispiel #2
0
parser.add_argument('--loss_scale', type=str, default=None)
parser.add_argument('--channels_last', type=bool, default=False)

# others
parser.add_argument('--seed', type=int, default=2, help='random seed')
parser.add_argument('--note',
                    type=str,
                    default='try',
                    help='note for this run')

args, unparsed = parser.parse_known_args()

args.save = os.path.join(
    args.save, 'eval-{}-{}'.format(time.strftime("%Y%m%d-%H%M%S"), args.note))
if args.local_rank == 0:
    create_exp_dir(args.save, scripts_to_save=None)

    log_format = '%(asctime)s %(message)s'
    logging.basicConfig(stream=sys.stdout,
                        level=logging.INFO,
                        format=log_format,
                        datefmt='%m/%d %I:%M:%S %p')
    fh = logging.FileHandler(os.path.join(args.save, 'log.txt'))
    fh.setFormatter(logging.Formatter(log_format))
    logging.getLogger().addHandler(fh)

if hasattr(torch, 'channels_last') and hasattr(torch, 'contiguous_format'):
    if args.channels_last:
        memory_format = torch.channels_last
    else:
        memory_format = torch.contiguous_format