Layer¶
- class dragon.vm.tensorflow.keras.layers.Layer(
 trainable=True,
 name=None,
 dtype=None,
 **kwargs
 )[source]¶
- The base class of layers. - Inherit this class to design a new layer: - class MyLayer(tf.keras.layers.Layer): def __init__(): super(MyModule, self).__init__() 
__init__¶
- Layer.- __init__(
 trainable=True,
 name=None,
 dtype=None,
 **kwargs
 )[source]¶
- Create a - Layer.- Parameters:
- trainable (bool, optional, default=True) – The initial training flag.
- name (str, optional) – The layer name.
- dtype (dragon.vm.tensorflow.dtypes.DType) – The optional data type.
 
 
Properties¶
non_trainable_weights¶
- Layer.- non_trainable_weights¶
- Return the non-trainable weights. - Returns:
- Sequence[dragon.vm.tensorflow.Variable] – The non-trainable weights.
 
trainable¶
- Layer.- trainable¶
- Return the trainable indicator. - Returns:
- bool – Trueif trainable otherwiseFalse.
 
Methods¶
add_weight¶
- Layer.- add_weight(
 name=None,
 shape=None,
 dtype=None,
 initializer=None,
 regularizer=None,
 trainable=True,
 use_resource=None,
 **kwargs
 )[source]¶
- Add a new variable as the weight. - Parameters:
- name (str, optional) – The optional variable name.
- shape (Sequence[int], optional) – The variable shape.
- dtype (str, optional) – The optional data type.
- initializer (Union[callable, str], optional) – The optional initializer.
- regularizer (Union[callable, str], optional) – The optional regularizer.
- trainable (bool, optional, default=True) – Trueto add to thetrainablecollection.
- use_resource (bool, optional, default=True) – Trueto set as aResourceVariable.
 
 
build¶
call¶
- Layer.- call(
 *args,
 **kwargs
 )[source]¶
- Define the implementation of forward. - Parameters:
- args... (Sequence[dragon.Tensor]) – The input tensors.
 
 - Returns:
- Sequence[dragon.Tensor] – The output tensors. 
 
