Skip to content

forestagostinelli/AIForAll

Repository files navigation

AI for All


Code to reproduce instructional material for AI for All.

Installation

If a conda session is active run:
conda deactivate

Then run:
conda env create -f environment.yml
conda activate aiforall

Running Scripts

Linear regression

python linear_regression.py --lr <learning_rate> --steps <training_steps> --bias <dataset bias>
Switches:
No bias parameter: --no_bias

Examples:
No bias parameter: python linear_regression.py --lr 0.1 --no_bias
No bias parameter with biased data: python linear_regression.py --lr 0.1 --bias 3 --no_bias
Bias parameter with biased data: python linear_regression.py --lr 0.1 --bias 3

Use the slider to go through the training steps.

Logistic regression

python logistic_regression.py --lr <learning_rate> --steps <training_steps>

Use the slider to go through the training steps.

Examples:
python logistic_regression.py

2-dimensional Neural Network classification

python 2D_train.py --dataset <dataset_name> --steps <training_steps> --lr <learning_rate>
Dataset names: lin, xor, half_moons
Change model in "EDIT HERE" and see how it performs

For specific xor classification visualization:
python 2D_train_xor.py --steps <training_steps> --lr <learning_rate>

Train Neural Network for MNIST Classification

python mnist_train.py
Change model in "EDIT HERE" and see how it performs

Test Neural Network on MNIST Classification

python mnist_test.py --nnet <nnet_file> --dim <size_of_plot>
Switches:
Linear model: --lin

Examples:
Linear model: python mnist_test.py --nnet models/mnist/mnist_lin.pt --dim 500 --lin
Neural network: python mnist_test.py --nnet models/mnist/mnist_lenet.pt --dim 500

MNIST Autoencoders

Training

Autoencoder: python train_mnist_ae.py --save_dir <nnet_directory>
Variational autoencoder: python train_mnist_ae.py --save_dir <nnet_directory> --vae
Conditional variational autoencoder: python train_mnist_ae.py --save_dir <nnet_directory> --cvae

Viewing latent space and reconstructions

Autoencoder:
python test_ae_gen.py --nnet models/mnist_ae/
python test_ae_gen.py --nnet models/mnist_ae_color/ --cmnist
Variational autoencoder:
python test_ae_gen.py --nnet models/mnist_vae/ --vae
python test_ae_gen.py --nnet models/mnist_vae_color/ --vae --cmnist
Conditional variational autoencoder:
python test_ae_gen.py --nnet models/mnist_cvae/ --digit <number>
python test_ae_gen.py --nnet models/mnist_cvae_color/ --digit <number> --color <color_idx> --cmnist

Visualizing data

python visualization/visualize_mnist.py --data <dataset name>

Recordings

About

Code to reproduce instructional materials for AI for all.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published