In this seminar we will learn about the latest research in eXplainable AI (XAI) and its application for the field of affective computing. This reposity will contain a series of Jupyter Notebooks to give you practical experience in implementing state-of-the-art explainablity techniques using various Python packages.
We will use Anaconda for the management of virtual environments and python package installations.
Download and install miniconda, a lightweight installation of anaconda (if you already have the full version of anaconda installed, that will work as well).
After installing miniconda, you now have the ability to easily create and manage Python virtual environments using the conda
command. For the Jupyter Notebooks used in this seminar, we recommend you create a new virtual environment to manage the various Python packages we will use through out the semester.
If you're not already familiar with conda
, you may want to familiarize your self with the documentation and the various commands in this cheat sheet
To create a new virutal env for this seminar, run the following commands from your conda terminal.
- Create a new virtual env named 'ml_bias_seminar' with the latest version of Python3:
conda create -n sose24_xai_ac python=3.10
- Activate the new virtual env:
conda activate sose24_xai_ac
- Install the required Python packages (The requirements.txt will be updated to include all necessary packages for the notebook assignments)
pip install -r requirements.txt
All notebooks during the semester will be provided through this GitHub repository. The easiest way to obtain the notebooks is to clone
this repository, and then perfrom a git pull
when we announce that new notebooks are available. Here I will provide terminal instructions to clone and pull the repo, but you are free to use your preferred GUI or Git interface.
-
To
clone
the repository:- First make sure you have in a directory where you would like to store the repository
git clone \<LINK TO REPO\>
- This will download all the current notebooks and material into a folder named <REPO NAME>
-
If we announce a new notebook or repository changes, then
pull
from the repo to get the latest material- make sure you are in the cloned directory named <REPO NAME>
- run:
git pull
- You should recieve a message indicating new files were downloaded
For this seminar, we will use JupyterLab to run and manage our Notebooks.
- Start JupyterLab
- make sure you virtual env is activated
- run:
jupyter lab
- This should automatically open JupyterLab in your browswer window
- if not, open the URL provided in your terminal output
- To create a new Notebook
- Go to the "Launcher" tab and click the Python icon in the "Notebook" section
- To open an existing notebook
- In the file explorer pane on the left, browse to an
.ipynb
file and doubleclick it
- In the file explorer pane on the left, browse to an
To validate your virtual env installation, and make sure you are able to run a simple notebook
- In JupyterLab, open
validate_installation.ipynb
- Follow the instructions in the Notebook
As an example, you can also familiarize yourself with the Notebook we will use in our first lecture: intro_ml.ipynb
To get started with Notebook 1:
Note: these instructions assume you've previously cloned the repository and set up your python environment per the above instructions. If not, return to the beginning of the README and follow the installation instructions.
- Update your local repository with
git pull
- Activate your conda env (if not already activated):
conda activate sose24_xai_ac
- Update your conda env with the latest python packages:
pip install -r requirements.txt
- Download necessary models from Moodle, section Jupyter Notebook #1.
- Extract files to the
models
folder in your local repository
- Extract files to the
- Launch Jupyter Lab:
jupyter lab
- Test importing tensorflow and other packages from the
requirements.txt
file- You can also test loading the tensorflow model:
# make sure you've downloaded the models from Moodle
model_path = '../models/affectnet_model_e=60/affectnet_model'
# load the weights
model_xai = cnn_model(input_shape=(128, 128, 3), num_classes=8)
model_xai.load_weights(model_path).expect_partial()
- Open the notebook called
notebooks/1. simplification_attribution.ipynb
- Follow the instructions in the notebook
To get started with Notebook 2:
Note: these instructions assume you've previously cloned the repository and set up your python environment per the above instructions. If not, return to the beginning of the README and follow the installation instructions.
- Update your local repository with
git pull
- Activate your conda env (if not already activated):
conda activate sose24_xai_ac
- Update your conda env with the latest python packages:
pip install -r requirements.txt
- Download necessary models from Moodle, section Jupyter Notebook #2.
- Extract files to the
models
folder in your local repository
- Extract files to the
- Launch Jupyter Lab:
jupyter lab
- In this session, I've created two notebooks to make each task easier to manage
- Notebook 2 Part 1:
notebooks/2.1 dice_cfs_ser.ipynb
- Notebook 2 Part 1:
notebooks/2.2 shap_attribution_ser.ipynb
- Notebook 2 Part 1:
- Open each notebook and ensure you can successfully run the imports statements
- If not, try recreating your conda environment
- Email me for support
- Follow the instructions in the notebook to complete the tasks