π‘ Guidelineο
To install and use the library, it is recommended to create a Python virtual environment. You can do that with virtualenv, as follows:
Setting environementο
pip install virtualenv
virtualenv -p <path/to/python3.10> myenv
source myenv/bin/activate
Installationο
Once your virtual environment is activated, you can install the uqmodels library directly from Pypi by typing :
pip install robust-ml
This command will install the robust-ml package and all required dependencies.
Input/Outputο
Inputο
Advertrain takes a torch dataloader as input.
Ouputο
As output, the library returns a model saved as a local .pth file.
Usage patternο
You have to generate a dataloader in pytorch.
trainer = AdversarialTraining(model=your_architecture, optimizer=your_optimizer, loss_func=your_criterion, device=your_device, epsilon=your_epsilon)
trainer.fit(epochs=2, train_dataloader=your_train_dataloader, val_dataloader=your_val_dataloader, patience=2, checkpoint=your_path)
For more informations, you can follow the notebook example here : Notebook
How to run the provided exampleο
Download the example dataset here and unzip it in the
examples/
folder. Once done, you should have subfolder named/examples/dataset/c00
Launch the jupyter notebook
examples/training.ipynb