gianlp.keras_layers.masked_embedding.MaskedEmbedding
- class gianlp.keras_layers.masked_embedding.MaskedEmbedding(*args, **kwargs)
Bases:
EmbeddingSpecial class for a masked at 0 embedding. It guarantees that the index 0 always maps to a vector of zeros.
- Parameters
input_dim – Size of the vocabulary, i.e. maximum integer index + 1.
output_dim – Integer. Dimension of the dense embedding.
**kwargs –
extra arguments to pass to Embedding init
Methods
add_lossAdd loss tensor(s), potentially dependent on layer inputs.
add_metricAdds metric tensor to the layer.
add_updateAdd update op(s), potentially dependent on layer inputs.
add_variableDeprecated, do NOT use! Alias for add_weight.
add_weightAdds a new variable to the layer.
buildCreates the variables of the layer (for subclass implementers).
build_from_configBuilds the layer's states with the supplied config dict.
Wraps the original call for guaranteeing masking :param inputs: inputs to forward the layer :return: output of the forward pass
compute_maskComputes an output mask tensor.
compute_output_shapeComputes the output shape of the layer.
compute_output_signatureCompute the output tensor signature of the layer based on the inputs.
count_paramsCount the total number of scalars composing the weights.
finalize_stateFinalizes the layers state after updating layer weights.
from_configCreates a layer from its config.
get_build_configReturns a dictionary with the layer's input shape.
get_configReturns the config of the layer.
get_input_atRetrieves the input tensor(s) of a layer at a given node.
get_input_mask_atRetrieves the input mask tensor(s) of a layer at a given node.
get_input_shape_atRetrieves the input shape(s) of a layer at a given node.
get_output_atRetrieves the output tensor(s) of a layer at a given node.
get_output_mask_atRetrieves the output mask tensor(s) of a layer at a given node.
get_output_shape_atRetrieves the output shape(s) of a layer at a given node.
get_weightsReturns the current weights of the layer, as NumPy arrays.
load_own_variablesLoads the state of the layer.
save_own_variablesSaves the state of the layer.
set_weightsSets the weights of the layer, from NumPy arrays.
with_name_scopeDecorator to automatically enter the module name scope.
Attributes
activity_regularizerOptional regularizer function for the output of this layer.
compute_dtypeThe dtype of the layer's computations.
dtypeThe dtype of the layer weights.
dtype_policyThe dtype policy associated with this layer.
dynamicWhether the layer is dynamic (eager-only); set in the constructor.
inbound_nodesReturn Functional API nodes upstream of this layer.
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_specInputSpec instance(s) describing the input format for this layer.
lossesList of losses added using the add_loss() API.
metricsList of metrics added using the add_metric() API.
nameName of the layer (string), set in the constructor.
name_scopeReturns a tf.name_scope instance for this class.
non_trainable_variablesSequence of non-trainable variables owned by this module and its submodules.
non_trainable_weightsList of all non-trainable weights tracked by this layer.
outbound_nodesReturn Functional API nodes downstream of this layer.
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.
statefulsubmodulesSequence of all sub-modules.
supports_maskingWhether this layer supports computing a mask using compute_mask.
trainabletrainable_variablesSequence of trainable variables owned by this module and its submodules.
trainable_weightsList of all trainable weights tracked by this layer.
updatesvariable_dtypeAlias of Layer.dtype, the dtype of the weights.
variablesReturns the list of all layer variables/weights.
weightsReturns the list of all layer variables/weights.
- call(inputs)
Wraps the original call for guaranteeing masking :param inputs: inputs to forward the layer :return: output of the forward pass