Complex input/output in tensorflow/keras neural networks is possible?

Viewed 1512

I've heard that is possible to feed a neural network built using tensorflow/keras with complex data and get a complex output specifying the "dtype" of each layer = tf.complex64 (or similar).

X = K.Input(shape = (n_taps,1), dtype = tf.complex64)
fc1 = K.layers.LSTM(n_fc1,activation="tanh",dtype = tf.complex64)  (X)

The declaration of each single layer does not give errors but calling the second layer giving as argument the first layer (2nd line I mean) gives the following expected error:

TypeError: Input 'b' of 'MatMul' Op has type float32 that does not match type complex64 of argument 'a'.

I did not understand if it's possible or not have this kind of network. Has anyone more informations about this? Thanks in advance

1 Answers

It's because K.layers.LSTM doesn't support tf.complex64 types. You would need to implement the layer yourself. You should start by subclassing tf.keras.layers.Layer, of which you can find an example in the docs of tf.keras.layers.Layer. The example is called the SimpleDense layer.

Related