autopycoin.layers.UnivariateLayer#
- class autopycoin.layers.UnivariateLayer(*args, **kwargs)[source]#
Integrate a n_variates attribute to the layer.
This layer aims to be inherited. During compilation if the model is a
autopycoin.models.UnivariateModelit can propagate to this layer a n_variates attribute which can be added to its internal weights shape during building phase with the get_additional_shapes method. This layer inherit fromautopycoin.layers.QuantileLayerthen get_additional_shapes has also the quantiles dimension.Usually, you will use this layer inside a
autopycoin.models.UnivariateModelhence the transpose operation needed to fit the keras norm (see post_processing method) is not usefull here. Hence we created an apply_multivariate_transpose attribute accessible in constructor which decides if the layer has to transpose the outputs tensors and to convert them intoautopycoin.extension_type.UnivariateTensor. by default, it is set to False but if you decides to use this layer inside tf.keras.Model set it to True.Notes
def build(self, inputs_shape): self.get_additional_shapes(0) + output_shape # get the quantile shape and add it where you need it
- Attributes
- init_params(inputs_shape: Union[tensorflow.python.framework.tensor_shape.TensorShape, List[tensorflow.python.framework.tensor_shape.TensorShape]], n_variates: Union[None, List[Union[None, int]]] = None, is_multivariate: Union[None, bool] = None, additional_shapes: Union[None, List[List[int]]] = None) None[source]#
Initialize attributes related to univariate model.
It is called before build. Three steps are done: - Filter the first shape in case of multiple inputs tensors. - Initialize attributes: is_multivariate, n_variates. - Add the n_variates dimension to additional_shape.
- preprocessing(inputs: Union[List[Union[tensorflow.python.framework.ops.Tensor, autopycoin.extension_type.QuantileTensor, autopycoin.extension_type.UnivariateTensor]], tensorflow.python.framework.ops.Tensor, autopycoin.extension_type.QuantileTensor, autopycoin.extension_type.UnivariateTensor]) Union[tensorflow.python.framework.ops.Tensor, tensorflow.python.ops.variables.Variable, autopycoin.extension_type.UnivariateTensor][source]#
Init the multivariates attributes and transpose the nvariates dimension in first position.