noise=0) G_target_normalized = out_normalizer.normalize(G_target) loss = build_graph_loss2(G_out, G_target_normalized) loss.backward() if step % 10 == 0: writer.add_scalar('loss', loss.data.item(), step) step += 1 for param in gn.parameters(): if param.grad is not None: param.grad.clamp_(-3, 3) optimizer.step() schedular.step() if step % 10000 == 0: torch.save(gn.state_dict(), savedir + '/model_{}.pth'.format(step)) iter = 0 sum_loss = 0 # evaluation loop, done every epoch for i, data in tqdm(enumerate(dl_eval)): action, delta_state, last_state = data action, delta_state, last_state = action.float(), \ delta_state.float(), last_state.float() if use_cuda: action, delta_state, last_state = action.cuda(),\ delta_state.cuda(), last_state.cuda() init_graph_features(G1,
G_target_normalized = out_normalizer.normalize(G_target) loss = build_graph_loss2(G_out, G_target_normalized) loss.backward() if step % 10 == 0: writer.add_scalar('loss', loss.data.item(), step) step += 1 for param in gn.parameters(): if not param.grad is None: param.grad.clamp_(-3,3) optimizer.step() schedular.step() if step % 10000 == 0: torch.save( gn.state_dict(), savedir + '/model_{}.pth'.format(step)) iter = 0 sum_loss = 0 #evaluation loop, done every epoch for i,data in tqdm(enumerate(dl_eval)): action, delta_state, last_state = data action, delta_state, last_state = action.float(), delta_state.float(), last_state.float() if use_cuda: action, delta_state, last_state = action.cuda(), delta_state.cuda(), last_state.cuda() init_graph_features(G1, graph_feat_size, node_feat_size, edge_feat_size, cuda=True, bs = 200) load_graph_features(G1, action, last_state, delta_state, bs=200, noise = 0)