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

ComplexDense Layer Fails Due to add_weight Error in cvnn Package #55

Open
ADzac opened this issue Nov 18, 2024 · 0 comments
Open

ComplexDense Layer Fails Due to add_weight Error in cvnn Package #55

ADzac opened this issue Nov 18, 2024 · 0 comments

Comments

@ADzac
Copy link

ADzac commented Nov 18, 2024

I encountered an error while using the ComplexDense layer from the cvnn package. The error appears to occur in the build method of ComplexDense, specifically when calling self.add_weight. The issue is that Layer.add_weight() raises a TypeError, stating it got multiple values for the shape argument.

Below is a minimal code snippet to reproduce the issue:

import cvnn.layers as complex_layers
import tensorflow as tf
from cvnn import activations as cactivations

model = tf.keras.models.Sequential()
model.add(complex_layers.ComplexInput(input_shape=(51, 51, 1)))
model.add(complex_layers.ComplexConv2D(32, (3, 3), activation=cactivations.cart_relu))
model.add(complex_layers.ComplexAvgPooling2D((2, 2)))
model.add(complex_layers.ComplexConv2D(64, (3, 3), activation=cactivations.cart_relu))
model.add(complex_layers.ComplexMaxPooling2D((2, 2)))

model.add(complex_layers.ComplexDense(64, activation=cactivations.cart_relu))
model.add(complex_layers.ComplexDense(10, activation=cactivations.convert_to_real_with_abs))

Error traceback :

File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\cvnn\layers\core.py:229, in ComplexDense.build(self, input_shape)
225 else:
226 raise ValueError(f"Unsuported init_technique {self.init_technique}, "
227 f"supported techniques are {INIT_TECHNIQUES}")
--> 229 self.w_r = self.add_weight('kernel_r',
230 shape=(input_shape[-1], self.units),
231 dtype=self.my_dtype.real_dtype,
232 initializer=self.kernel_initializer,
233 trainable=True,
234 constraint=self.kernel_constraint, regularizer=self.kernel_regularizer)
235 #self.w_r = tf.Variable(
236 # name='kernel_r',
237 # initial_value=self.kernel_initializer(shape=(input_shape[-1], self.units), dtype=i_kernel_dtype),
238 # trainable=True
239 #)
240 self.w_i = self.add_weight('kernel_i',
241 shape=(input_shape[-1], self.units),
242 dtype=self.my_dtype.real_dtype,
243 initializer=self.kernel_initializer,
244 trainable=True,
245 constraint=self.kernel_constraint, regularizer=self.kernel_regularizer)

TypeError: Layer.add_weight() got multiple values for argument 'shape'"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant