Helper functions

There is an important custom loss function that is needed for the generator network: the self-regularization loss. We'll define this function as though it's part of our helper functions in the generator:

  1. Define self-regularization loss as follows:
def self_regularization_loss(self,y_true,y_pred):
return tf.multiply(0.0002,tf.reduce_sum(tf.abs(y_pred-y_true)))
  1. Create the summary helper function, as follows:
def summary(self):
return self.Generator.summary()
  1. Define the save_model_graph function as in previous sections, as follows:
def save_model_graph(self):
plot_model(self.Generator, to_file='/out/Generator_Model.png')

  1. Save the model h5 file if requested by the user with the following code:
def save_model(self,epoch,batch):
self.Generator.save('/out/'+self.NAME+'_Epoch_'+epoch+'_Batch_'+batch+
'model.h5')
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.240.244