region:us
EEGNet V4 is implemented using Braindecode version 0.8.1 and Skorch version 0.15. 

## Model details
<ul>
  <li>Architecture: EEGNet by Lawhern et al.</li>
  <li>Accuracy: 86%</li>
  <li>NonTarget recall: 0.86</li> 
  <li>NonTarget precision: 0.97</li> 
  <li>Target recall: 0.84</li> 
  <li>Target precision: 0.54</li>
</ul> 

## Training details
<ul>
  <li>Trained on the Lee 2019 ERP dataset (http://moabb.neurotechx.com/docs/generated/moabb.datasets.Lee2019_ERP.html#moabb.datasets.Lee2019_ERP)</li>
  <li>Dropout rate of 25%</li>
  <li>Class rebalanced weighting of the labels after data preprocessing</li>
  <li>8 spatial filters with 2 temporal filters per spatial filter</li>
  <li>Batch size of 128</li>
  <li>Dataset is shuffled and a random 20% is used as a validation set</li>
  <li>trained for 1000 epochs, model with the lowest validation loss is saved</li>
</ul> 

## Get started with the Model

```python
from braindecode.models import EEGNetv4
from huggingface_hub import hf_hub_download
from skorch import NeuralNet
import torch.nn as nn
import torch as th

path_params = hf_hub_download(
    repo_id='guido151/EEGNetv4',
    filename='EEGNetv4_Lee2019_ERP/params.pt',
)
path_optimizer = hf_hub_download(
    repo_id='guido151/EEGNetv4',
    filename='EEGNetv4_Lee2019_ERP/optimizer.pt',
)
path_history = hf_hub_download(
    repo_id='guido151/EEGNetv4',
    filename='EEGNetv4_Lee2019_ERP/history.json',
)
path_criterion = hf_hub_download(
    repo_id='guido151/EEGNetv4',
    filename='EEGNetv4_Lee2019_ERP/criterion.pt',
)

model = EEGNetv4(
        n_chans=19,
        n_outputs=2,
        n_times=128,
)
  
net = NeuralNet(
    model,
    criterion=nn.CrossEntropyLoss(weight=th.tensor([1, 1])),
)
net.initialize()
net.load_params(
    path_params,
    path_optimizer,
    path_criterion,
    path_history,
)

```

## Get the FID model

```python
def get_fid_model(model: EEGNetv4) -> nn.Module:
    fid_model = deepcopy(model)
    for i in range(len(fid_model)):
        if i >= 14:
            fid_model[i] = Identity()
    fid_model.eval()
    for param in fid_model.parameters():
        param.requires_grad = False
    return fid_model
```
## Get the IS model

```python
def get_is_model(model: EEGNetv4) -> nn.Module:
    is_model = deepcopy(model)
    is_model.eval()
    for param in is_model.parameters():
        param.requires_grad = False
    return is_model
```