NEGU93 / cvnn

Library to help implement a complex-valued neural network (cvnn) using tensorflow as back-end
https://complex-valued-neural-networks.readthedocs.io/
MIT License
164 stars 34 forks source link

Unknown activation function 'cart_relu': Please ensure this object is passed to 'custom objects' argument #37

Closed Priyanshu-bee closed 1 year ago

Priyanshu-bee commented 1 year ago

getting this error while trying to use complex activation functions with ComplexConv layers. Doesn't give any error while using the complex activations with the complex dense layer....

NEGU93 commented 1 year ago

Could you please provide a Minimum Working Example (MWE) to reproduce the error? A plus would be the working scenario.

Thank you

Priyanshu-bee commented 1 year ago

from tensorflow.keras import datasets, models import cvnn.layers as complex_layers

model = models.Sequential() model.add(complex_layers.ComplexConv2D(32, (3, 3), activation='cart_relu', input_shape=(32, 32, 3), dtype=np.float32))

running the above is causing the given error, it is working when replacing activation with just 'relu'. As far as I could understand while defining Complex conv layers you have imported activations from tensorflow.keras and then used activations.get(activation) which might be raising an issue as these activations are defined and created by you and importing t_activations might enable us to use these complex activations.

NEGU93 commented 1 year ago

For me it's working. See it here.

NEGU93 commented 1 year ago

Try updating cvnn version to the latest.

Also, beware that the example cast to np.float32 and not complex.

Priyanshu-bee commented 1 year ago

I used conda to install cvnn, that was giving the error. After doing pip install it works, thanks!!!