Code implementation – loss functions
In this section, we're going to develop custom loss functions that will be used for the discriminator, generator, and adversarial models. We'll cover two loss functions in this section, which we'll go over in detail.
Getting ready
It's time for a directory check! Make sure you've created and placed the relevant data in each of the following folders and files. In this step, we're adding the loss.py
file:
├── data ├── docker │ ├── build.sh │ ├── clean.sh │ ├── Dockerfile │ └── kaggle.json ├── out ├── README.md ├── run.sh └── src ├── loss.py
How to do it...
This is a fairly simple section made up of three primary steps—creating the loss.py
file and placing two loss functions in it for us to inherit later on in the development.
Perform the following steps to create the loss.py
file:
- Add the
python3
interpreter to the top of the file and importtensorflow
, as follows:
#!/usr/bin/env python3 import tensorflow as tf
- Implement the self-regularization loss...