Esempio n. 1
0
"""


chain_net = Chain_net()

if A['load_net']:
    #best_path = find_best_net(A['net_path'])
    best_path = most_recent_file_in_folder(A['net_path'])
    cg("Loading net from",best_path)
    chain_net.load_state_dict(torch.load(best_path))

#chain_net = torch.nn.DataParallel(chain_net)
chain_net.to(device)
cg('chain_net.to(device)')
criterion = nn.MSELoss()
optimizer = optim.Adam(chain_net.parameters(), A['learning_rate']) #, lr=0.001)

os_system('mkdir -p',A['net_path'])

A['ctr0'] = 0


cg('starting training loop')

#k200 = nn.Upsample((200,200),mode='nearest')


data_manager = utils.DataManager(A['data_path'])
kprint(data_manager.D,r=0,title='data_manager')

Esempio n. 2
0
modes = ['train', 'val']

chain_net = Chain_net()

if A['load_net']:
    #best_path = find_best_net(A['net_path'])
    best_path = most_recent_file_in_folder(A['net_path'])
    cg("Loading net from", best_path)
    chain_net.load_state_dict(torch.load(best_path))

#chain_net = torch.nn.DataParallel(chain_net)
chain_net.to(device)

criterion = nn.MSELoss()
optimizer = optim.Adam(chain_net.parameters(),
                       A['learning_rate'])  #, lr=0.001)

os_system('mkdir -p', A['net_path'])

A['ctr0'] = 0

while not A['time']['to_exit'].rcheck():  # A['ctr0'] < A['max_steps']: #

    for mode in ['train', 'train', 'train', 'val']:  #modes:
        A['ctr0'] += 1

        t0 = time.time()

        if len(C[mode]['current_indicies']) < A['batch_size'] * 2:
Esempio n. 3
0
chain_net = torch.quantization.prepare_qat(chain_net_fused)

#print(chain_net.state_dict())

if A['load_net']:
    best_path = most_recent_file_in_folder(A['net_path'])
    cg("Loading net from", best_path)
    chain_net.load_state_dict(torch.load(best_path))

chain_net.to(device)
chain_net_original.to(device)
cg('chain_net.to(device)')
criterion = nn.MSELoss()
optimizer_Q = optim.Adam(chain_net.parameters(),
                         A['learning_rate'])  #, lr=0.001)
optimizer = optim.Adam(chain_net_original.parameters(),
                       A['learning_rate'])  #, lr=0.001)

os_system('mkdir -p', A['net_path'])

A['ctr0'] = 0

cg('starting training loop')

data_manager = utils.DataManager(A['data_path'])
kprint(data_manager.D, r=0, title='data_manager')

all_done = False

while not A['time']['to_exit'].rcheck() and not all_done: