You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The output of the print statement above indicates that the custom activation function was added successfully. Maybe the crash is related to "built=False"?
# output of print statementget_custom_objects()={'fourier': <Activation name=activation, built=False>}
The error message reads:
# error message
Traceback (most recent call last):
File "/home/orca/Downloads/minimal_tf_err.py", line 20, in<module>
layer_2 = tf.keras.layers.Dense(100, input_shape = [5],
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/orca/.local/lib/python3.12/site-packages/keras/src/layers/core/dense.py", line 89, in __init__
self.activation = activations.get(activation)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/orca/.local/lib/python3.12/site-packages/keras/src/activations/__init__.py", line 104, in get
raise ValueError(
ValueError: Could not interpret activation functionidentifier: fourier
The text was updated successfully, but these errors were encountered:
In the example above, you are passing the string "fourier" as activation. A string is not a tensor-in tensor-out callable, so it doesn't work as an activation.
I added "fourier" as a key in the global dictionary of custom objects, as described here:
# add fourier function to global dictionary of custom objectsget_custom_objects()["fourier"] =Activation(fourier)
Further, the code runs successfully on my old computer (using TensorFlow 2.10.0). Instead of crashing it runs to the end and outputs the model summary:
I originally posted this issue in the TensorFlow GitHub, and was told it looks like a Keras issue and I should post it here.
TensorFlow version:
2.17.0
OS:
Linux Mint 22
Python version:
3.12.7
Issue:
I can successfully define a custom activation function, but when I try to use it TensorFlow crashes.
Minimal reproducible example:
The output of the print statement above indicates that the custom activation function was added successfully. Maybe the crash is related to "built=False"?
The error message reads:
The text was updated successfully, but these errors were encountered: