Esempio n. 1
0
net.train()

# TODO: Create optimizer for network parameters from conv2 onwards
# (do not optimize conv1)

conv_layer_numbers = [0]
for elt in conv_layer_numbers:
    net.features[elt].weight.requires_grad = False
    net.features[elt].bias.requires_grad = False
'''for param in net.parameters():
        print(param.shape)
        print(param.requires_grad)     #Freeze the features part of the network
        print("==================================================================================")'''

optimizer = torch.optim.SGD(filter(lambda p: p.requires_grad,
                                   net.parameters()),
                            lr=lr,
                            momentum=momentum,
                            weight_decay=weight_decay)

if not os.path.exists(output_dir):
    os.makedirs(output_dir)

if use_tensorboard:
    import time
    timestr = time.strftime("%Y%m%d-%H%M%S")
    save_path = "runs/" + timestr + '/'
    writer = SummaryWriter(save_path)

if use_visdom:
    import visdom
        print('Did not find {}'.format(name))
        continue

# Move model to GPU and set train mode
net.cuda()
net.train()

#pdb.set_trace()

log_dir = '/home/bjasani/Desktop/CMU_HW/VLR/HW2/hw2-release/code/tf_logs/faster_rcnn'
logger = Logger(log_dir, name='faster_rcnn_6_ysh')
vis = visdom.Visdom(port='8106')
vis.text('Hello, world!')

# Create optimizer for network parameters
params = list(net.parameters())
optimizer = torch.optim.SGD(params[2:],
                            lr=lr,
                            momentum=momentum,
                            weight_decay=weight_decay)

if not os.path.exists(output_dir):
    os.makedirs(output_dir)

# training
train_loss = 0
tp, tf, fg, bg = 0., 0., 0, 0
step_cnt = 0
re_cnt = False
t = Timer()
t.tic()
Esempio n. 3
0
        print('Did not find {}'.format(name))
        continue

log_path = os.path.join("./wsddn_log/",
                        datetime.now().strftime('%Y-%m-%d_%H-%M-%S'))
os.makedirs(log_path)
logger = Logger(log_path, 'http://localhost', '8097', use_visdom=True)

# Move model to GPU and set train mode
net.load_state_dict(own_state)
net.cuda()
net.train()

# TODO: Create optimizer for network parameters from conv2 onwards
# (do not optimize conv1)
opt_param = list(net.parameters())
optimizer = torch.optim.SGD(opt_param[2:],
                            lr=lr,
                            momentum=momentum,
                            weight_decay=weight_decay)

if not os.path.exists(output_dir):
    os.makedirs(output_dir)

# training
firstFlag = True
train_loss = 0
tp, tf, fg, bg = 0., 0., 0, 0
step_cnt = 0
re_cnt = False
t = Timer()