I have a complex-valued (input,output) data, and I wanted to train a fully complex network using keras in TensorFlow 2.0. I wrote a loss function which returns real value, and customized it into keras. Similarly, I added some complex-valued activation functions in the hidden layer, and the model started to learn successfully. However, when I tried to customize the complex weight and bias initialization in a similar procedure, it gives an error. For clarity here is what I tried to do.
def initialize_weight(shape, dtype= None):
real = K.random_uniform(shape, dtype = dtype)
imag = K.random_normal(shape, dtype=dtype)
return tf.complex(real,imag)
model_new = Sequential()
model_new.add(Dense(20, input_dim=x_train.shape[0], kernel_initializer = initialize_weight,activation = myrelu))
model_new.add(Dense(10, kernel_initializer = intilialize_weight, activation = myrelu))
model_new.add(Dense(y_train.shape[0], kernel_initializer = initialize_weight, activation = myrelu))
model_new.compile(loss= mse_error, optimizer='adam', metric = 'accuracy')
model_new.summary()
The error message is: * ValueError: Tensor conversion requested dtype float32 for Tensor with dtype complex64:
Notice that, the activation myrelu and the loss function mse_error are custom functions. The error is only due to the kernel_initializer. Is there a way to customize a complex-valued weight in keras please ? I really appreciate any support on this. Thanks !