PatchDiscriminator¶
Inheritance Diagram

-
class
ashpy.models.convolutional.discriminators.PatchDiscriminator(input_res, min_res, kernel_size, initial_filters, filters_cap, use_dropout=True, dropout_prob=0.3, non_linearity=<class 'tensorflow.python.keras.layers.advanced_activations.LeakyReLU'>, normalization_layer=<class 'ashpy.layers.instance_normalization.InstanceNormalization'>, use_attention=False)[source]¶ Bases:
ashpy.models.convolutional.encoders.BaseEncoderPix2Pix discriminator: The last layer is an image in which each pixels is the probability of being fake or real.
Examples
x = tf.ones((1, 64, 64, 3)) # instantiate the PathDiscriminator patchDiscriminator = PatchDiscriminator(input_res=64, min_res=16, kernel_size=5, initial_filters=64, filters_cap=512, ) # evaluate passing x output = patchDiscriminator(x) # the output shape is the same as the input shape print(output.shape)
(1, 12, 12, 1)
Methods
__init__(input_res, min_res, kernel_size, …)PatchDiscriminator used by pix2pix, when min_res=1 this is the same as a standard fully convolutional discriminator
call(inputs[, training, return_features])Execute the model on input data.
Attributes
activity_regularizerOptional regularizer function for the output of this layer.
dtypedynamicinbound_nodesDeprecated, do NOT use! Only for compatibility with external Keras.
inputRetrieves the input tensor(s) of a layer.
input_maskRetrieves the input mask tensor(s) of a layer.
input_shapeRetrieves the input shape(s) of a layer.
input_specGets the network’s input specs.
layerslossesLosses which are associated with this Layer.
metricsReturns the model’s metrics added using compile, add_metric APIs.
metrics_namesReturns the model’s display labels for all outputs.
nameReturns the name of this module as passed or determined in the ctor.
name_scopeReturns a tf.name_scope instance for this class.
non_trainable_variablesnon_trainable_weightsoutbound_nodesDeprecated, do NOT use! Only for compatibility with external Keras.
outputRetrieves the output tensor(s) of a layer.
output_maskRetrieves the output mask tensor(s) of a layer.
output_shapeRetrieves the output shape(s) of a layer.
run_eagerlySettable attribute indicating whether the model should run eagerly.
sample_weightsstate_updatesReturns the updates from all layers that are stateful.
statefulsubmodulesSequence of all sub-modules.
trainabletrainable_variablesSequence of variables owned by this module and it’s submodules.
trainable_weightsupdatesvariablesReturns the list of all layer variables/weights.
weightsReturns the list of all layer variables/weights.
-
__init__(input_res, min_res, kernel_size, initial_filters, filters_cap, use_dropout=True, dropout_prob=0.3, non_linearity=<class 'tensorflow.python.keras.layers.advanced_activations.LeakyReLU'>, normalization_layer=<class 'ashpy.layers.instance_normalization.InstanceNormalization'>, use_attention=False)[source]¶ PatchDiscriminator used by pix2pix, when min_res=1 this is the same as a standard fully convolutional discriminator
- Parameters
input_res (int) – Input Resolution
min_res (int) – Minimum Resolution reached by the discriminator
kernel_size (int) – Kernel Size used in Conv Layer
initial_filters (int) – number of filters in the first convolutional layer
filters_cap (int) – Maximum number of filters
use_dropout (bool) – whether to use dropout
dropout_prob (float) – probability of dropout
non_linearity (
tf.keras.layers.Layer) – non linearity used in the modelnormalization_layer (
tf.keras.layers.Layer) – normalization layer used in the modeluse_attention (bool) – whether to use attention
-
_add_building_block(filters, use_bn=False)[source]¶ Construct the core of the
tf.keras.Model.The layers specified here get added to the
tf.keras.Modelmultiple times consuming the hyper-parameters generated in the_get_layer_spec().- Parameters
filters (int) – Number of filters to use for this iteration of the Building Block.
-
_add_final_block(output_shape)[source]¶ Take the results of
_add_building_block()and prepare them for the for the final output.- Parameters
output_shape (int) – Amount of units of the last
tf.keras.layers.Dense
-