Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Activation Functions with tensorflow 2.8.2 #31

Open
AdamPrystupiuk opened this issue Jul 5, 2022 · 1 comment
Open

Custom Activation Functions with tensorflow 2.8.2 #31

AdamPrystupiuk opened this issue Jul 5, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@AdamPrystupiuk
Copy link

Hello! Recently there was an update of tensorflow from 2.8.0 to 2.8.2 on google collab and since then my codes involving custom activation functions stopped working properly (it works fine after reinstalling older version of tensorflow).

The error i get is the following: ("c_modu" is the new activation function i added in cvnn/activations.py)

image
Any input on why that is would be greatly appreciated!

@NEGU93 NEGU93 added the bug Something isn't working label Jul 31, 2023
@maorgranot1
Copy link

For me 'modrelu' became functional again when I replaced it's code in cvnn/activations.py

from :
"
def modrelu(z: Tensor, b: float = 1., c: float = 1e-3) -> Tensor:
abs_z = tf.math.abs(z)
return tf.cast(tf.keras.activations.relu(abs_z + b), dtype=z.dtype) * z / tf.cast(abs_z + c, dtype=z.dtype)
"

to:
"
def modrelu(z: Tensor, b: float = 1., c: float = 1e-3) -> Tensor:
abs_z = tf.math.abs(z)
r_relu = tf.keras.activations.relu(abs_z + b)
return tf.complex(r_relu * tf.math.real(z) / (abs_z + c), r_relu * tf.math.imag(z) / (abs_z + c))
"

It might be less efficient but it solved the bug for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants