string_replace
StringReplaceLayer ¤
StringReplaceLayer(
string_match_constant=None,
string_replace_constant=None,
regex=False,
name=None,
input_dtype=None,
output_dtype=None,
**kwargs
)
Bases: BaseLayer
StringReplaceLayer layer for TensorFlow.
Initialises the StringReplaceLayer layer.
WARNING: While it works, the use of tensors in matching/replacement is not recommended due to the complexity of the regex matching which requires use of a map_fn. This will be comparatively VERY slow and may not be suitable for inference use-cases. If you know where in the string the match is, you will be much better off slicing the string and checking for equality.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
string_match_constant |
Optional[str]
|
The string to match against and replace. Defaults to |
None
|
string_replace_constant |
Optional[str]
|
The string to replace the matched string with. Defaults to |
None
|
regex |
bool
|
Whether to treat the string match as a regular expression. Defaults to |
False
|
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
|
Source code in src/kamae/keras/tensorflow/layers/string_replace.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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
compatible_dtypes
property
¤
compatible_dtypes
get_config ¤
get_config()
Gets the configuration of the StringReplace layer. Used for saving and loading the layer from disk.
Specifically, regex, string_match_constant and string_replace_constant
are added to the config.
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dictionary configuration of the layer. |
Source code in src/kamae/keras/tensorflow/layers/string_replace.py
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 | |