def test_eegnet_v1(input_sizes): model = EEGNetv1(input_sizes['n_channels'], input_sizes['n_classes'], input_window_samples=input_sizes['n_in_times']) check_forward_pass( model, input_sizes, )
def test_eegnet_v1(): rng = np.random.RandomState(42) n_channels = 18 n_in_times = 500 n_classes = 2 n_samples = 7 X = rng.randn(n_samples, n_channels, n_in_times, 1) X = torch.Tensor(X.astype(np.float32)) model = EEGNetv1(n_channels, n_classes, input_window_samples=n_in_times) y_pred = model(X) assert y_pred.shape == (n_samples, n_classes)
cuda = torch.cuda.is_available( ) # check if GPU is available, if True chooses to use it device = 'cuda' if cuda else 'cpu' if cuda: torch.backends.cudnn.benchmark = True seed = 20200220 # random seed to make results reproducible # Set random seed to be able to reproduce results set_random_seeds(seed=seed, cuda=cuda) n_classes = 3 # Extract number of chans and time steps from dataset n_chans = train_set[0][0].shape[0] input_window_samples = train_set[0][0].shape[1] #model = ShallowFBCSPNet(n_chans,n_classes,input_window_samples=input_window_samples,final_conv_length='auto',) model = EEGNetv1(n_chans, n_classes, input_window_samples) # Send model to GPU if cuda: model.cuda() #x = torch.randn(1, n_chans, input_window_samples) # input: torch.Size([64, 64, 500]) #y=model(x) # These values we found good for shallow network: lr = 0.0625 * 0.01 weight_decay = 0 batch_size = 64 n_epochs = 4 clf = EEGClassifier( model,