-
Notifications
You must be signed in to change notification settings - Fork 38
Description
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'"
}