Closed SantaTitular closed 2 years ago
Dear @SantaTitular,
First of all, thank you for using my library and your interest in my work. It is really appreciated.
I believe the issue is that the output activation function (linear
) just outputs a complex number, however, categorical cross-entropy is only defined for real numbers. Here you have 2 options:
Hope it helps! let me know if the issue is solved.
Dead @NEGU93 ,
Thanks alot for the response!
Although I did manage to run the code, my problem was the implementation of the library in the anaconda environment. For instance, I replicated the example that you mentioned here, and I got several module errors (e.g., ModuleNotFoundError: No module named 'cvnn.losses' ). Afterwards I just imported the cvnn library (which I installed with conda install -c negu93 cvnn ) and I only have the following modules:
Do you think that this might be an environment issue or an incompatibility with some version of spyder, tensorflow, numpy, etc.? I tried reinstalling and ran into several conflicts between libraries and still could not have some of the modules. Am I doing anything wrong?
Thanks in advance!
Conda version is outdated and does not have the losses module. I recommend you install cvnn with pip (within the conda environment, there is no problem with that).
All your suggestions worked wonderfully, thank you so much, your library will be a tremendous help!
Edit: Feel free to close the thread!
Great! I'm very glad I could help. I will then close the issue.
Hello,
I came here after reading your article: Complex-Valued Vs. Real-Valued Neural Networks for Classification Perspectives: An Example on Non-Circular Data and I think that your CVNN implementation would be extremely helpfull in my research. However, when I tried to install through Anaconda, I get compatibility issues with the spider and/or tensorflow library. I tried the following situations:
In the first situation, after dealing with the conflits, I get the following error when running your example code:
In the second situation, I am unable to install tensorflow as anaconda is unable to deal with the conflits (?)
Any chance you could help me figuring out the issue or pointing out a different solution?
Thanks alot in advance!
*Edit PS: the code:
-- coding: utf-8 --
""" Created on Mon Sep 27 17:24:47 2021
@author: tomas """
import numpy as np from scipy.io import loadmat import matplotlib.pyplot as plt
import tensorflow as tf import cvnn.layers as complex_layers
=============================================================================
freq_range = loadmat('freq_range.mat')['freq_range']
X = loadmat('X.mat')['X']
Y = loadmat('Y.mat')['Y']
=============================================================================
input_shape = (4, 28, 28, 3) x = tf.cast(tf.random.normal(input_shape), tf.complex64)
model = tf.keras.models.Sequential() model.add(complex_layers.ComplexInput(input_shape=input_shape[1:])) model.add(complex_layers.ComplexFlatten()) model.add(complex_layers.ComplexDense(units=64, activation='cart_relu')) model.add(complex_layers.ComplexDense(units=10, activation='linear')) model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
y = model(x)