# Set Training parameters
params = Tester.TestParams()
params.subnet_name = 'detection_subnet'
params.gpus = [0]
params.ckpt = './demo/models/ckpt_baseline_resnet101.h5'
params.batch_size = 25 * len(params.gpus)
params.print_freq = 100

# validation data
valid_data = get_loader(json_path,
                        data_dir,
                        mask_dir,
                        inp_size,
                        feat_stride,
                        preprocess='resnet',
                        batch_size=params.batch_size - 10 * len(params.gpus),
                        training=False,
                        shuffle=False,
                        num_workers=8,
                        subnet=params.subnet_name)
print('val dataset len: {}'.format(len(valid_data.dataset)))

# model
if backbone == 'resnet101':
    model = poseNet(101)
elif backbone == 'resnet50':
    model = poseNet(50)

for name, module in model.named_children():
    for para in module.parameters():
    if name in fpn_retinanet_para:
        for para in module.parameters():
            para.requires_grad = False
for name, module in model.named_children():
    if name in retinanet_para:
        for para in module.parameters():
            para.requires_grad = False
for name, module in model.named_children():
    if name in prn_para:
        for para in module.parameters():
            para.requires_grad = False

print("Loading dataset...")
# load training data
train_data = get_loader(json_path, data_dir,
                        mask_dir, inp_size, feat_stride,
                        'resnet', params.batch_size,
                        shuffle=True, training=True, num_workers=8)
print('train dataset len: {}'.format(len(train_data.dataset)))

# load validation data
valid_data = None
if params.val_nbatch > 0:
    valid_data = get_loader(json_path, data_dir, mask_dir, inp_size,
                            feat_stride, preprocess='resnet', training=False,
                            batch_size=params.batch_size-2*len(params.gpus), shuffle=False, num_workers=8)
    print('val dataset len: {}'.format(len(valid_data.dataset)))

trainable_vars = [param for param in model.parameters() if param.requires_grad]
if opt == 'adam':
    print("Training with adam")
    params.optimizer = torch.optim.Adam(