Conv2DInterface¶
Inheritance Diagram

-
class
ashpy.models.convolutional.interfaces.Conv2DInterface[source]¶ Bases:
tensorflow.python.keras.engine.training.ModelPrimitive Interface to be used by all
ashpy.models.Methods
__init__()Primitive Interface to be used by all ashpy.models.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__()[source]¶ Primitive Interface to be used by all
ashpy.models.Declares the self.model_layers list.
-
static
_get_layer_spec(initial_filers, filters_cap, input_res, target_res)[source]¶ Compose the
layer_spec, the building block of a convolutional model.The
layer_specis an iterator. Every element returned is the number of filters to learn for the current layer. The generated sequence of filters startsfrom initial_filtersand halve/double the number of filters depending on theinput_resandtarget_res. Ifinput_res > target_resthe number of filters increases, else it decreases. The progression is always a power of 2.Parameters: Yields: int – Number of filters to use for the conv layer.
Examples
# Encoder class T(Conv2DInterface): pass spec = T._get_layer_spec( initial_filers=16, filters_cap=128, input_res=(512, 256), target_res=(32, 16) ) print([s for s in spec]) spec = T._get_layer_spec( initial_filers=16, filters_cap=128, input_res=(28, 28), target_res=(7, 7) ) print([s for s in spec]) # Decoder spec = T._get_layer_spec( initial_filers=128, filters_cap=16, input_res=(32, 16), target_res=(512, 256) ) print([s for s in spec]) spec = T._get_layer_spec( initial_filers=128, filters_cap=16, input_res=(7, 7), target_res=(28, 28) ) print([s for s in spec])
[32, 64, 128, 128] [32, 64] [64, 32, 16, 16] [64, 32]
Notes
This is useful since it enables us to dynamically redefine models sharing an underlying architecture but with different resolutions.
-