reference = js["nodes_reference"] base_nodes = map(int, js["nodes_base"].split(',')) stack_nodes = map(int, js["nodes_stack"].split(',')) final_nodes = [] #map(int, js["nodes_final"].split(',')) num_att = 4 num_output = 3 renetFile = None if 'retrain' in js: renetFile = HOME + 'NNs/' + js['retrain'] + '.p' if mode == 'train': tr = DataSet(tr_data, js['block'], feature_len) # tr.set_t_scale(t_scale) tr.set_num_output(num_output) te = DataSet(te_data, js['block'], feature_len) # te.set_t_scale(t_scale) te.set_num_output(num_output) else: if mode == 'te': te = DataSet(te_data, js['block'], feature_len) else: te = DataSet(tr_data, js['block'], feature_len) te.set_num_output(num_output) sz_in = te.sz loop = js['loop'] print "input shape", sz_in, "LR", lr, 'feature', feature_len if renetFile is not None:
iterations = 10000 js = Utils.load_json_file(config_file) dtype = torch.float device = torch.device("cpu") # device = torch.device("cuda:0") # Uncomment this to run on GPU cfg = Config(config_file) tr = DataSet(cfg.tr_data, cfg.memory_size, cfg.feature_len) te = DataSet(cfg.te_data, cfg.memory_size, cfg.feature_len) tr.set_net_type(cfg.net_type) te.set_net_type(cfg.net_type) tr.set_t_scale(cfg.t_scale) te.set_t_scale(cfg.t_scale) tr.set_num_output(cfg.num_output) te.set_num_output(cfg.num_output) att = te.sz[1] D_in = cfg.feature_len * att D_out = cfg.num_output tr_pre_data = tr.prepare(multi=1) for b in tr_pre_data: d = torch.from_numpy(b[0]).type(torch.FloatTensor) t = torch.from_numpy(b[1]).type(torch.FloatTensor) te_pre_data = te.prepare(multi=1) for b in te_pre_data: de = torch.from_numpy(b[0]).type(torch.FloatTensor) te = torch.from_numpy(b[1]).type(torch.FloatTensor)