Code Monkey home page Code Monkey logo

Comments (5)

nipulseervi avatar nipulseervi commented on May 27, 2024

remove dype or change it to tf.complex64

eg:
import tensorflow as tf
tf. device("gpu:1")
model = tf.keras.models.Sequential()
model.add(complex_layers.ComplexInput(input_shape=input_shape))
model.add(complex_layers.ComplexConv2D(32, (2, 2), activation='cart_leaky_relu', padding='same'))
model.add(complex_layers.ComplexMaxPooling2D((2, 2)))
model.add(complex_layers.ComplexConv2D(64, (2, 2), activation='cart_leaky_relu', padding='same'))
model.add(complex_layers.ComplexMaxPooling2D((2, 2)))
model.add(complex_layers.ComplexConv2D(128, (2, 2), activation='cart_leaky_relu', padding='same'))
model.add(complex_layers.ComplexMaxPooling2D((2, 2)))
model.add(complex_layers.ComplexConv2D(256, (2, 2), activation='cart_leaky_relu', padding='same'))
model.add(complex_layers.ComplexMaxPooling2D((2, 2)))
model.add(complex_layers.ComplexFlatten())

from cvnn.

fafrincs avatar fafrincs commented on May 27, 2024

@nipulseervi Thank you for your previous help. I've successfully removed the dtype and modified the activations to "cart_leaky_relu", it removed the warning. However, I'm wondering if this "cvnn" library other activation functions can handle complex numbers directly without considering the real and imaginary parts separately.
I've tried using activation functions like modrelu, crelu, and zrelu, but I keep receiving the following warning:
“WARNING:tensorflow:You are casting an input of type complex64 to an incompatible dtype float32. This will discard the imaginary part and may not be what you intended.”
I would like to know if these activations can handle complex numbers directly, preserving both the real and imaginary parts. I would appreciate any guidance on how to use these models.

from cvnn.

maorgranot1 avatar maorgranot1 commented on May 27, 2024

This solution might not be efficient but it solved the error for 'modrelu'.
Within cvnn/activations.py change the function modrelu to:
"
def modrelu(z: Tensor, b: float = 1., c: float = 1e-3) -> Tensor:
abs_z = tf.math.abs(z)
mod_relu = tf.keras.activations.relu(abs_z + b)
return tf.complex(mod_relu * tf.math.real(z) / (abs_z + c), mod_relu * tf.math.imag(z) / (abs_z + c))
"

from cvnn.

NEGU93 avatar NEGU93 commented on May 27, 2024

Sorry for my late reply.
This error was because of your line that uses 'relu' activation function. Here you are using Tensorflow ReLU. Tensorflow is not prepared to deal with complex values so it cast it to float. My library then realizes this happens and because I cannot go to Tensorflow to change stuff I at least warn you about this. Please use only activation functions from cvnn toolbox or code an activation function yourself.

from cvnn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.