コード例 #1
0
np.random.seed(1)
torch.manual_seed(1)


# In[5]:


# Load data
data_dir = '../../new_data_folder/'
kfold_number = 0

logDir = 'models_and_stats/'
model_name = 'BT19_ae_{}_rm_{}_wrI_{}_wC_{}_{}'.format(data_reduction_ratio, removal, w_r, w_c, str(kfold_number))
device = torch.device("cuda:{}".format(args.cuda))
print("Loading data...")
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)


# 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,
コード例 #2
0
data_dir = '../../new_data_folder/'
kfold_number = args.kfold

num_class = 20
learning_rate = 0.0001
num_epochs = 5000
hidden_size = 40
num_layers = 1
dropout = 0.2

logDir = 'models_and_stat/'
model_name = 'cnn_lstm_icub_' + str(kfold_number)
device = torch.device("cuda:{}".format(args.cuda))

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

# ### set module

# In[5]:


# define NN models
class CNN(nn.Module):
    def __init__(self):
        super(CNN, self).__init__()
        self.conv1 = nn.Conv2d(in_channels=1,
                               out_channels=3,
                               kernel_size=(3, 5))