Commit 8afc7c98 authored by Guillaume HEUSCH's avatar Guillaume HEUSCH

[doc] removed guide for ConvAutoEncoder and MLP

parent 9a5af10c
Pipeline #28574 passed with stage
in 22 minutes and 4 seconds
.. py:currentmodule:: bob.learn.pytorch
=============================
Convolutional autoencoder
=============================
Autoencoder training on RGB facial data
===========================================================
This section introduces a work-flow for training a convolutional autoencoder. An autoencoder discussed in this section is introduced the following publication [NGM19]_. It is recommended to check the publication for better understanding of the architecture of the autoencoder, as well as for potential application of autoencoders in biometrics (face PAD in this case).
As an example, to train an autoencoder on facial images extracted from the CelebA database, you can use the following command:
.. code-block:: sh
./bin/train_network.py \ # script used for autoencoders training, can be used for other networks as-well
<FOLDER_CONTAINING_TRAINING_DATA> \ # substitute the path pointing to training data
<FOLDER_TO_SAVE_THE_RESULTS>/ \ # substitute the path to save the results to
-c autoencoder/net1_celeba.py \ # configuration file defining the AE, database, and training parameters
-cg bob.learn.pytorch.config \ # name of the group containing the configuration file
-vv # set verbosity level
People in Idiap can benefit from GPU cluster, running the training as follows:
.. code-block:: sh
jman submit --queue gpu \ # submit to GPU queue (Idiap only)
--name <NAME_OF_EXPERIMENT> \ # define the name of th job (Idiap only)
--log-dir <FOLDER_TO_SAVE_THE_RESULTS>/logs/ \ # substitute the path to save the logs to (Idiap only)
--environment="PYTHONUNBUFFERED=1" -- \ #
./bin/train_network.py \ # script used for autoencoders training, cand be used for other networks as-well
<FOLDER_CONTAINING_TRAINING_DATA> \ # substitute the path pointing to training data
<FOLDER_TO_SAVE_THE_RESULTS>/ \ # substitute the path to save the results to
-c autoencoder/net1_celeba.py \ # configuration file defining the AE, database, and training parameters
-cg bob.learn.pytorch.config \ # name of the group containing the configuration file
-gpu \ # enable the GPU mode
-vv # set verbosity level
For a more detailed documentation of functionality available in the training script, run the following command:
.. code-block:: sh
./bin/train_network.py --help # note: remove ./bin/ if buildout is not used
Please inspect the corresponding configuration file, ``net1_celeba.py`` for example, for more details on how to define the database, network architecture and training parameters.
Another key-component of the training procedure is availability of the training data. Please refer to the section entitled **Multi-channel face PAD using autoencoders** in the
documentation of ``bob.pad.face`` package, for an explicit example on how to compute the data suitable for training of the discussed network.
Using RGB facial images extracted from CelebA database, after ``NUM_EPOCHS = 70`` epochs of training, as defined in the ``net1_celeba.py`` configuration file, one can find in the ``<FOLDER_TO_SAVE_THE_RESULTS>``
the following reconstructions produced by an autoencoder:
.. figure:: img/conv_ae_after_70_epochs.png
:align: center
Output of convolutional autoencoder after 70 epochs of training
Autoencoder fine-tuning on the multi-channel facial data
===========================================================
This section is useful for those trying to reproduce the results form [NGM19]_, or for demonstrative purposes showing the capabilities of ``train_network.py`` script.
Following the training procedure of [NGM19]_, one might want to fine-tune the pre-trained autoencoder on the multi-channel (**MC**) facial data.
In this example, MC training data is a stack of gray-scale, NIR, and Depth (BW-NIR-D) facial images extracted from WMCA face PAD database.
For an explicit example on how to generate the MC (BW-NIR-D) training data, please refer to the section entitled **Multi-channel face PAD using autoencoders** in the
documentation of ``bob.pad.face`` package.
Once the training data is computed, you can use the below command to fine-tune an autoencoder, pre-trained on the RGB data. In this case **all** layers of an
autoencoder are fine-tuned.
.. code-block:: sh
./bin/train_network.py \ # script used for autoencoders training, can be used for other networks as-well
<FOLDER_CONTAINING_TRAINING_DATA> \ # substitute the path pointing to training data
<FOLDER_TO_SAVE_THE_RESULTS>/ \ # substitute the path to save the results to
-p <FOLDER_CONTAINING_RGB_AE_MODELS>/model_70.pth \ # initialize the AE with the model obtained during RGB pre-training
-c autoencoder/net1_batl.py \ # configuration file defining the AE, database, and training parameters
-cg bob.learn.pytorch.config \ # name of the group containing the configuration file
-cv \ # compute a loss on CV set after each epoch
-vv # set verbosity level
Below is the command allowing to fine-tine just **one layer of encoder**, which performs better in face PAD task according to findings in [NGM19]_.
.. code-block:: sh
./bin/train_network.py \ # script used for autoencoders training, can be used for other networks as-well
<FOLDER_CONTAINING_TRAINING_DATA> \ # substitute the path pointing to training data
<FOLDER_TO_SAVE_THE_RESULTS>/ \ # substitute the path to save the results to
-p <FOLDER_CONTAINING_RGB_AE_MODELS>/model_70.pth \ # initialize the AE with the model obtained during RGB pre-training
-c autoencoder/net1_batl_3_layers_partial.py \ # configuration file defining the AE, database, and training parameters
-cg bob.learn.pytorch.config \ # name of the group containing the configuration file
-cv \ # compute a loss on CV set after each epoch
-vv # set verbosity level
.. note::
People in Idiap can benefit from GPU cluster, running training commands similar to an example in the previous section.
.. figure:: img/mc_conv_ae_3_layers_tuning_50_epochs.png
:align: center
Output of convolutional autoencoder after 50 epochs of **partial** fine-tuning on BW-NIR-D data.
.. [NGM19] *O. Nikisins, A. George, S. Marcel*, **Domain Adaptation in Multi-Channel Autoencoder based Features for Robust Face Anti-Spoofing**,
in: Submitted to: 2019 International Conference on Biometrics (ICB), 2019.
.. py:currentmodule:: bob.learn.pytorch
=============================
Multilayer perceptron
=============================
Multilayer perceptron training
===========================================================
This section introduces a work-flow for training a Multilayer perceptron (MLP). Training details, as well as the structure of the MLP are identical to the ones introduced the following publication [NGM19]_. It is recommended to check the publication for better understanding of the below discussions.
In [NGM19]_, an MLP is trained on concatenation of latent embeddings of multiple autoencoders. For an explicit example on how to compute latent embeddings for MLP training, please refer to the section entitled **Multi-channel face PAD using autoencoders** in the documentation of ``bob.pad.face`` package. In general, latent embeddings of a sample is just a 1D numpy array.
As an example, to train an autoencoder on latent embeddings extracted from an entire multi-channel (BW-NIR-D) faces of WMCA database, one can use the following command:
.. code-block:: sh
./bin/train_network.py \ # script used for MLP training, can be used for other networks as-well
<FOLDER_CONTAINING_TRAINING_DATA> \ # substitute the path pointing to training data
<FOLDER_TO_SAVE_THE_RESULTS>/ \ # substitute the path to save the results to
-c mlp/batl_db_1296x10_relu_mlp.py \ # configuration file defining the database, training parameters, transformation to be applied to training data, and an MLP architecture
-cg bob.learn.pytorch.config \ # name of the group containing the configuration file
-cv \ # compute the loss on the cross-validation set as-well
-vv # set verbosity level
Please inspect the corresponding configuration file, ``batl_db_1296x10_relu_mlp.py``, for more details on how to define the database, network architecture and training parameters. Additionally, ``batl_db_1296x10_relu_mlp.py`` defines a transformation function, applying mean-std normalization to the input training samples.
After above script is completed, models are saved in ``<FOLDER_TO_SAVE_THE_RESULTS>`` directory, and one can select the "best" model having the lowest loss on the cross-validation set, by inspecting the log file located in the same directory.
.. note::
People in Idiap can benefit from GPU cluster, running training commands similar to an example from section on **Convolutional autoencoder**.
......@@ -15,8 +15,6 @@ Users Guide
user_guide.rst
guide_dcgan.rst
guide_conditionalgan.rst
guide_conv_autoencoder.rst
guide_mlp.rst
guide_mccnn_pad.rst
guide_audio_extractor.rst
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment