k += 1 return p_means, p_covariances, q_means, q_covariances, num_phones_mask spk = 0 phone = 2 # Get all the p/q vects pkl_file = '/home/alta/BLTSpeaking/exp-vr313/data/mfcc13/GKTS4-D3/grader/BLXXXgrd02/BLXXXgrd02.pkl' pkl = pickle.load(open(pkl_file, "rb")) print("loaded pkl") # get the phones phones = get_phones() max_len_frames = 4000 p_vects, q_vects, p_mask, q_mask, mask = get_vects(pkl, phones, max_len_frames) # Convert to pytorch tensors p_vects = torch.from_numpy(p_vects).float() q_vects = torch.from_numpy(q_vects).float() p_mask = torch.from_numpy(p_mask).float() q_mask = torch.from_numpy(q_mask).float() mask = torch.from_numpy(mask).float() # Apply torch operations # Get p/q_lengths p_lengths = torch.sum(p_mask[:, :, :, 0].squeeze(), dim=2).unsqueeze(dim=2).repeat(1, 1, 13) q_lengths = torch.sum(q_mask[:, :, :, 0].squeeze(), dim=2).unsqueeze(dim=2).repeat(1, 1, 13)
checkpoint = args.checkpoint # Save the command run if not os.path.isdir('CMDs'): os.mkdir('CMDs') with open('CMDs/training_spectral_attack_mse.cmd', 'a') as f: f.write(' '.join(sys.argv) + '\n') pkl = pickle.load(open(pkl_file, "rb")) print("Loaded pkl") # Get the phones phones = get_phones() # Get the batched tensors X1, X2, M1, M2 = get_vects(pkl, phones, N, F) # Get the output labels y = (pkl['score']) # Convert to tensors X1 = torch.from_numpy(X1).float() X2 = torch.from_numpy(X2).float() M1 = torch.from_numpy(M1).float() M2 = torch.from_numpy(M2).float() y = torch.FloatTensor(y) # Split into training and validation sets validation_size = 50 X1_train = X1[validation_size:] X1_val = X1[:validation_size]