Example #1
0
def prepare_common_settings():
    # work directory (saving log and model weights)
    config_dict['timestamp'] = time.strftime('%Y%m%d_%H%M%S', time.localtime())
    config_dict['work_dir'] = './' + os.path.basename(__file__).split(
        '.')[0] + '_work_dir_' + config_dict['timestamp']

    # copy current config file to work dir for backup
    if not os.path.exists(config_dict['work_dir']):
        os.makedirs(config_dict['work_dir'])
    shutil.copyfile(
        __file__,
        os.path.join(config_dict['work_dir'], os.path.basename(__file__)))

    # log file path
    config_dict['log_path'] = os.path.join(
        config_dict['work_dir'], 'log_' + config_dict['timestamp'] + '.log')

    # set exception hook, record all output info including exceptions and errors
    sys.excepthook = customize_exception_hook(
        os.path.join(config_dict['work_dir'],
                     'exception_log_' + config_dict['timestamp'] + '.log'))

    # training epochs
    config_dict['training_epochs'] = 1000

    # reproductive
    config_dict['seed'] = 666
    config_dict['cudnn_benchmark'] = True
    if config_dict['seed'] is not None:
        set_random_seed(config_dict['seed'])
    set_cudnn_backend(config_dict['cudnn_benchmark'])

    # GPU list
    config_dict['gpu_list'] = [0, 1, 2, 3]
    assert isinstance(config_dict['gpu_list'], list)

    # display interval in iterations
    config_dict['display_interval'] = 100

    # checkpoint save interval in epochs
    config_dict['save_interval'] = 100

    # validation interval in epochs
    config_dict['val_interval'] = 0
Example #2
0
# log file path
config_dict['log_path'] = os.path.join(config_dict['work_dir'], 'log_' + config_dict['timestamp'] + '.log')

# training epochs
config_dict['training_epochs'] = 12

# batch size
config_dict['batch_size'] = 2

# reproductive
config_dict['seed'] = 1
config_dict['cudnn_benchmark'] = True
if config_dict['seed'] is not None:
    set_random_seed(config_dict['seed'])
set_cudnn_backend(config_dict['cudnn_benchmark'])

# GPU list
config_dict['gpu_list'] = [0]
assert isinstance(config_dict['gpu_list'], list)

# display interval in iterations
config_dict['display_interval'] = 10

# checkpoint save interval in epochs
config_dict['save_interval'] = 12

# validation interval in epochs
config_dict['val_interval'] = 1

'''