Here are key steps in this piece, and they are as follows:
- Define all of the imports for the discriminator and utilize python3 as follows:
#!/usr/bin/env python3
import sys
import numpy as np
from keras.layers import Input, Dense, Reshape, Flatten, Dropout, BatchNormalization, Lambda, Concatenate, MaxPooling2D
from keras.layers.core import Activation
from keras.layers.convolutional import Convolution2D
from keras.layers.advanced_activations import LeakyReLU
from keras.activations import relu
from keras.models import Sequential, Model
from keras.optimizers import Adam, SGD,Nadam, Adamax
from keras.utils import plot_model
import tensorflow as tf
from loss import Loss
- Create the Discriminator class and add the following initialization step:
class Discriminator(object):
def __init__(self, width = 35, height= 55, channels =
1,name='discriminator'):
- Using the variables we instantiated the class with, initialize the following internal self variables:
self.W = width
self.H = height
self.C = channels
self.SHAPE = (width,height,channels)
self.NAME = name
- Create the model and the optimizer and then compile your model with the local adversarial loss function, as follows:
self.Discriminator = self.model()
self.OPTIMIZER = SGD(lr=0.001)
self.Discriminator.compile(loss=Loss.local_adversarial_loss,
optimizer=self.OPTIMIZER)
- Save the model graphic and print a summary, as follows:
self.save_model_graph()
self.summary()