sub_string_delim_at_index
SubStringDelimAtIndexLayer ¤
SubStringDelimAtIndexLayer(
name=None,
input_dtype=None,
output_dtype=None,
delimiter="_",
index=0,
default_value="",
**kwargs
)
Bases: BaseLayer
Layer which splits a string tensor by a delimiter and returns the substring at the specified index. If the delimiter is the empty string, the string is split into bytes/characters. If the index is negative, start counting from the end of the string. If the index is out of bounds, the default value is returned.
Initialise the SubStringDelimAtIndexLayer layer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
Optional[str]
|
The name of the layer. Defaults to |
None
|
input_dtype |
Optional[str]
|
The dtype to cast the input to. Defaults to |
None
|
output_dtype |
Optional[str]
|
The dtype to cast the output to. Defaults to |
None
|
delimiter |
str
|
String to split on. Defaults to |
'_'
|
index |
int
|
Index of the substring to return. Defaults to |
0
|
default_value |
str
|
Value to return if index is out of bounds. Defaults to |
''
|
Source code in src/kamae/keras/tensorflow/layers/sub_string_delim_at_index.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
compatible_dtypes
property
¤
compatible_dtypes
get_config ¤
get_config()
Returns the config of the SubStringDelimAtIndex layer. Used for saving and loading from a model.
Specifically adds the delimiter, index and default_value to the config.
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dictionary of the config of the layer. |
Source code in src/kamae/keras/tensorflow/layers/sub_string_delim_at_index.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | |
resolve_negative_indices
staticmethod
¤
resolve_negative_indices(ragged_tensor, index)
Resolves negative indices to positive indices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ragged_tensor |
RaggedTensor
|
Ragged tensor |
required |
index |
int
|
The index to resolve. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
The resolved index. |
Source code in src/kamae/keras/tensorflow/layers/sub_string_delim_at_index.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |