예제 #1
0
    spike_ready=False,
    batch_size=batch_size,
    shuffle=shuffle)
test_loader, test_dataset = get_testLoader(data_dir,
                                           spike_ready=False,
                                           batch_size=batch_size,
                                           shuffle=shuffle)

# Initialize models
model_B = VRAEC(num_class=num_class,
                sequence_length=sequence_length_B,
                number_of_features=number_of_features_B,
                hidden_size=hidden_size,
                hidden_layer_depth=hidden_layer_depth,
                latent_length=latent_length,
                batch_size=batch_size,
                learning_rate=learning_rate,
                n_epochs=n_epochs,
                dropout_rate=dropout_rate,
                cuda=cuda,
                model_name=model_name_B,
                header=header_B,
                device=device)
model_B.to(device)

model_I = VRAEC(num_class=num_class,
                sequence_length=sequence_length_I,
                number_of_features=number_of_features_I,
                hidden_size=hidden_size,
                hidden_layer_depth=hidden_layer_depth,
                latent_length=latent_length,
                batch_size=batch_size,
예제 #2
0
test_loader, test_dataset = get_testLoader(data_dir, spike_ready=False, batch_size=batch_size, shuffle=shuffle)


# In[6]:


# Create model
model = VRAEC(num_class=num_class,
            sequence_length=sequence_length,
            number_of_features = number_of_features,
            hidden_size = hidden_size, 
            hidden_layer_depth = hidden_layer_depth,
            latent_length = latent_length,
            batch_size = batch_size,
            learning_rate = learning_rate,
            n_epochs = n_epochs,
            dropout_rate = dropout_rate,
            cuda = cuda,
            print_every=print_every, 
            clip=clip, 
            max_grad_norm=max_grad_norm,
            dload = logDir,
            model_name=model_name,
            header=header,
            device = device)

model.to(device)


# In[7]:

예제 #3
0
test_loader, test_dataset = get_testLoader(data_dir,
                                           spike_ready=False,
                                           batch_size=batch_size,
                                           shuffle=shuffle)

# In[5]:

model_B_pretrained = VRAEC(num_class=num_class,
                           sequence_length=sequence_length_B,
                           number_of_features=number_of_features_B,
                           hidden_size=hidden_size,
                           hidden_layer_depth=hidden_layer_depth,
                           latent_length=latent_length,
                           batch_size=batch_size,
                           learning_rate=learning_rate,
                           n_epochs=n_epochs,
                           dropout_rate=dropout_rate,
                           cuda=cuda,
                           print_every=print_every,
                           clip=clip,
                           max_grad_norm=max_grad_norm,
                           dload=logDir,
                           model_name=model_name_B,
                           header=header_B,
                           device=device)
model_B_pretrained_dir = logDir + model_name_B + '.pt'
if device == torch.device('cpu'):
    model_B_pretrained.load_state_dict(
        torch.load(model_B_pretrained_dir, map_location=torch.device('cpu')))
else:
    model_B_pretrained.load_state_dict(torch.load(model_B_pretrained_dir))
예제 #4
0
    spike_ready=False,
    batch_size=batch_size,
    shuffle=shuffle)
test_loader, test_dataset = get_testLoader(data_dir,
                                           spike_ready=False,
                                           batch_size=batch_size,
                                           shuffle=shuffle)

# Initialize models
model_B = VRAEC(num_class=num_class,
                sequence_length=sequence_length_B,
                number_of_features=number_of_features_B,
                hidden_size=hidden_size,
                hidden_layer_depth=hidden_layer_depth,
                latent_length=latent_length,
                batch_size=batch_size,
                learning_rate=learning_rate,
                n_epochs=n_epochs,
                dropout_rate=dropout_rate,
                cuda=cuda,
                model_name=model_name_B,
                header=header_B,
                device=device)
model_B.to(device)

model_I = VRAEC(num_class=num_class,
                sequence_length=sequence_length_I,
                number_of_features=number_of_features_I,
                hidden_size=hidden_size,
                hidden_layer_depth=hidden_layer_depth,
                latent_length=latent_length,
                batch_size=batch_size,
예제 #5
0
if torch.cuda.is_available():
    device = torch.device("cuda:{}".format(args.cuda))
else:
    device = torch.device('cpu')
print("Loading data \n, load {} kfold number, put to device: {}".format(args.kfold, device))

train_loader, val_loader, train_dataset, val_dataset = get_trainValLoader(data_dir, k=kfold_number, spike_ready=False, batch_size=batch_size, shuffle=shuffle)
test_loader, test_dataset = get_testLoader(data_dir, spike_ready=False, batch_size=batch_size, shuffle=shuffle)

model_B_pretrained = VRAEC(num_class=num_class,
            sequence_length=sequence_length_B,
            number_of_features = number_of_features_B,
            hidden_size = hidden_size, 
            hidden_layer_depth = hidden_layer_depth,
            latent_length = latent_length,
            batch_size = batch_size,
            learning_rate = learning_rate,
            n_epochs = n_epochs,
            dropout_rate = dropout_rate, 
            cuda = cuda,
            model_name=model_name_B,
            header=header_B,
            device = device)
model_B_pretrained_dir = logDir+model_name_B+'.pt'

if device  == torch.device('cpu'):
    model_B_pretrained.load_state_dict(torch.load(model_B_pretrained_dir, map_location=torch.device('cpu')))
else:
    model_B_pretrained.load_state_dict(torch.load(model_B_pretrained_dir))
    
model_B_pretrained.to(device)
model_B_pretrained.eval()
test_loader, test_dataset = get_testLoader(data_dir,
                                           spike_ready=False,
                                           batch_size=batch_size,
                                           shuffle=shuffle)

# In[6]:

model_B = VRAEC(num_class=num_class,
                sequence_length=sequence_length_B,
                number_of_features=number_of_features_B,
                hidden_size=hidden_size,
                hidden_layer_depth=hidden_layer_depth,
                latent_length=latent_length,
                batch_size=batch_size,
                learning_rate=learning_rate,
                n_epochs=n_epochs,
                dropout_rate=dropout_rate,
                cuda=cuda,
                print_every=print_every,
                clip=clip,
                max_grad_norm=max_grad_norm,
                dload=logDir,
                model_name=model_name_B,
                header=header_B,
                device=device)
model_B.to(device)

model_I = VRAEC(num_class=num_class,
                sequence_length=sequence_length_I,
                number_of_features=number_of_features_I,
                hidden_size=hidden_size,
                hidden_layer_depth=hidden_layer_depth,