Skip to content

array_concatenate

ArrayConcatenateLayer ¤

ArrayConcatenateLayer(
    name=None,
    input_dtype=None,
    output_dtype=None,
    axis=-1,
    auto_broadcast=False,
    **kwargs
)

Bases: BaseLayer

Performs a concatenation of the input tensors.

Initialises the ArrayConcatenateLayer layer.

Parameters:

Name Type Description Default
name Optional[str]

The name of the layer. Defaults to None.

None
input_dtype Optional[str]

The dtype to cast the input to. Defaults to None.

None
output_dtype Optional[str]

The dtype to cast the output to. Defaults to None.

None
axis int

Axis to concatenate on. Defaults to -1.

-1
auto_broadcast bool

If True, will broadcast the input tensors to the biggest rank before concatenating. Defaults to False.

False
Source code in src/kamae/keras/core/layers/array_concatenate.py
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
def __init__(
    self,
    name: Optional[str] = None,
    input_dtype: Optional[str] = None,
    output_dtype: Optional[str] = None,
    axis: int = -1,
    auto_broadcast: bool = False,
    **kwargs: Any,
) -> None:
    """
    Initialises the ArrayConcatenateLayer layer.

    :param name: The name of the layer. Defaults to `None`.
    :param input_dtype: The dtype to cast the input to. Defaults to `None`.
    :param output_dtype: The dtype to cast the output to. Defaults to `None`.
    :param axis: Axis to concatenate on. Defaults to -1.
    :param auto_broadcast: If `True`, will broadcast the input tensors to the
    biggest rank before concatenating. Defaults to `False`.
    """
    super().__init__(
        name=name, input_dtype=input_dtype, output_dtype=output_dtype, **kwargs
    )
    if auto_broadcast and axis != -1:
        raise ValueError("auto_broadcast is only supported for axis=-1")
    self.axis = axis
    self.auto_broadcast = auto_broadcast

compatible_dtypes property ¤

compatible_dtypes

Returns the compatible dtypes of the layer. Returns None as the compatible dtypes are not restricted.

Returns:

Type Description
Optional[List[str]]

The compatible dtypes of the layer.

get_config ¤

get_config()

Gets the configuration of the ArrayConcatenate layer. Used for saving and loading from a model.

Specifically, adds the axis and auto_broadcast to the config.

Returns:

Type Description
Dict[str, Any]

Dictionary of the configuration of the layer.

Source code in src/kamae/keras/core/layers/array_concatenate.py
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
def get_config(self) -> Dict[str, Any]:
    """
    Gets the configuration of the ArrayConcatenate layer.
    Used for saving and loading from a model.

    Specifically, adds the `axis` and `auto_broadcast` to the config.

    :returns: Dictionary of the configuration of the layer.
    """
    config = super().get_config()
    config.update(
        {
            "axis": self.axis,
            "auto_broadcast": self.auto_broadcast,
        }
    )
    return config