interfaces¶
Primitive Convolutional interfaces.
Classes
Conv2DInterface |
Primitive Interface to be used by all ashpy.models. |
-
class
ashpy.models.convolutional.interfaces.Conv2DInterface[source]¶ Bases:
tensorflow.python.keras.engine.training.ModelPrimitive Interface to be used by all
ashpy.models.-
__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.
-