Пример #1
0
dataset.split = 'train'
dataloader = DataLoader(dataset,
                        batch_size=params['batchSize'],
                        shuffle=False,
                        num_workers=params['numWorkers'],
                        drop_last=True,
                        collate_fn=dataset.collate_fn,
                        pin_memory=False)

# Initializing visdom environment for plotting data
viz = VisdomVisualize(enable=bool(params['enableVisdom']),
                      env_name=params['visdomEnv'],
                      server=params['visdomServer'],
                      port=params['visdomServerPort'])
pprint.pprint(params)
viz.addText(pprint.pformat(params, indent=4))

# Setup optimizer
if params['continue']:
    # Continuing from a loaded checkpoint restores the following
    startIterID = params['ckpt_iterid'] + 1  # Iteration ID
    lRate = params['ckpt_lRate']  # Learning rate
    print("Continuing training from iterId[%d]" % startIterID)
else:
    # Beginning training normally, without any checkpoint
    lRate = params['learningRate']
    startIterID = 0

optimizer = optim.Adam(parameters, lr=lRate)
#############
##changed
Пример #2
0
if params['qaCategory'] and params['categoryMap']:
    category_mapping = json.load(open(params['categoryMap'], 'r'))
    val_split_name = split_names['val']
    test_split_name = split_names['test']
    category_mapping_splits = {
        'val': category_mapping[val_split_name][params['qaCategory']],
        'test': category_mapping[test_split_name][params['qaCategory']]
    }

# Plotting on vizdom
viz = VisdomVisualize(enable=bool(params['enableVisdom']),
                      env_name=params['visdomEnv'],
                      server=params['visdomServer'],
                      port=params['visdomServerPort'])
pprint.pprint(params)
viz.addText(pprint.pformat(params, indent=4))
logging.info("Running evaluation!")

numRounds = params['numRounds']
if 'ckpt_iterid' in params:
    iterId = params['ckpt_iterid'] + 1
else:
    iterId = -1

for split in splits:
    if split == 'train':
        splitName = 'full train - {}'.format(params['evalTitle'])
    if split == 'val': splitName = 'full Val - {}'.format(params['evalTitle'])
    if split == 'test': splitName = 'test - {}'.format(params['evalTitle'])

    logging.info("Using split %s" % split)