text_plain_output_1.png
input_height = nn_data[0][0].shape[1]
input_width = nn_data[0][0].shape[2]
conv_channels = [nn_data[0][0].shape[0], 4, 16, 64, 128]
kernels = [3, 3, 3, 3]
maxpools = [2, 2, 2, 2]
lin_channels = [256, 128, 20]
dropout = 0.25
learning_rate = 1e-05
weight_decay = 1e-06
patience = 10
verbose_ct = 1
epochs = 2500
model = CNNBackbone(input_height=input_height, input_width=input_width, conv_channels=conv_channels, kernels=kernels, maxpools=maxpools, lin_channels=lin_channels, dropout=dropout, batchnorm=True)
model.to(device)
loss_function = nn.CrossEntropyLoss()
optimizer = torch.optim.Adam(model.parameters(), lr=learning_rate, weight_decay=weight_decay)
t_losses, v_losses = train(model, train_loader, val_loader, optimizer, epochs, device=device, patience=patience, verbose_ct=verbose_ct)
plot_losses(t_losses, v_losses, 'CNN_Training_Loss.pdf')
predictions, labels = evaluate(model, test_loader, device=device)
y_true = np.concatenate(labels, axis=0)
y_pred = np.concatenate(predictions, axis=0)
print(classification_report(y_true, y_pred))