with open(lab_file, 'rb') as handle: lab = pickle.load(handle) with open(lab_file_dev, 'rb') as handle: lab_dev = pickle.load(handle) # Network initialization nnet=MLP(options,inp_dim) nnet.to(device) cost=nn.NLLLoss() # Optimizer initialization optimizer = optim.SGD(nnet.parameters(), lr=lr, momentum=0.0) # Seeds initialization np.random.seed(seed) torch.manual_seed(seed) # Batch creation (train) fea_lst=[] lab_lst=[] print("Data Preparation...") for snt in fea_pase.keys(): if fea_pase[snt].shape[0]-lab[snt].shape[0]!=2: if fea_pase[snt].shape[0]-lab[snt].shape[0]==3: fea_lst.append(fea_pase[snt][:-3]) lab_lst.append(lab[snt])
# Computing pase features for test fea_pase_dev = {} for snt_id in fea_dev.keys(): fea_pase_dev[snt_id] = pase(fea_dev[snt_id]).detach() fea_pase_dev[snt_id] = fea_pase_dev[snt_id].view( fea_pase_dev[snt_id].shape[1], fea_pase_dev[snt_id].shape[2]).transpose(0, 1) # Network initialization nnet = MLP(options, inp_dim) nnet.to(device) cost = nn.NLLLoss() # Optimizer initialization optimizer = optim.SGD(list(nnet.parameters()) + list(pase.parameters()), lr=lr, momentum=0.0) # Seeds initialization np.random.seed(seed) torch.manual_seed(seed) # Batch creation (train) fea_lst = [] lab_lst = [] print("Data Preparation...") for snt in fea_pase.keys(): fea_lst.append(fea_pase[snt]) lab_lst.append(