How does keras handle complex dataset?

1,102 views
Skip to first unread message

Noob

unread,
Jan 14, 2017, 5:18:49 PM1/14/17
to Keras-users
I am currently working with a dataset which has complex values, and seem to get a warning that I am bit concerned about. 


Train start
Train on 221286 samples, validate on 24588 samples
Epoch 1/150
/usr/local/lib/python2.7/dist-packages/numpy/core/numeric.py:482: ComplexWarning: Casting complex values to real discards the imaginary part
 
return array(a, dtype, copy=False, order=order)
221286/221286 [==============================] - 22s - loss: 0.0154 - val_loss: 0.0166
Epoch 2/150



How do I make it not discard the complex part.. ?

Any way around it?

Here is the code:
print "Model definition!"
    model
= Sequential()
model
.add(Dense(output_dim=13, input_dim=1025, init="normal",activation=K.tanh))

reduce_lr
=ReduceLROnPlateau(monitor='val_loss', factor=0.01, patience=3, verbose=1, mode='auto', epsilon=0.001, cooldown=0, min_lr=0.00000001)
    stop  
= EarlyStopping(monitor='val_loss', min_delta=0, patience=5, verbose=1, mode='auto')


    log
=csv_logger = CSVLogger('training_'+str(i)+'.csv')




    hist_current
= model.fit(train_set_data_vstacked_normalized[train],
                                train_set_output_vstacked_normlized
[train],
                                shuffle
=False,
                                validation_data
=(train_set_data_vstacked_normalized[test],train_set_output_vstacked_normlized[test]),
                                validation_split
=0.1,
                                nb_epoch
=150,
                                verbose
=1,
                                callbacks
=[reduce_lr,log,stop])


Matias Valdenegro

unread,
Jan 14, 2017, 6:31:11 PM1/14/17
to keras...@googlegroups.com

You could just treat complex numbers as 2D vectors (real and imaginary parts) and feed that to the neural network. You just need to preprocess the data correctly to just keep the real coefficients and not have complex numbers.

Noob

unread,
Jan 14, 2017, 7:20:32 PM1/14/17
to Keras-users
I am working with complex matrices.. so i've kind of done what you mention. Splitted into real and img, concatenated them, and doubled the input_dim. 
Lets see if it works. 

cr88...@gmail.com

unread,
Mar 8, 2018, 7:31:56 AM3/8/18
to Keras-users
I would like to know if finally your Idea worked because I'm facing the same situation with a matrix of complex values to train in Keras

manue...@gmail.com

unread,
Apr 28, 2018, 12:44:26 PM4/28/18
to Keras-users
Does anyone knows how to deal with complex numbers in keras? I have the same issue.

Regards

pachpan...@gmail.com

unread,
Feb 1, 2019, 10:27:32 AM2/1/19
to Keras-users
Did anyone solve this issue?

pachpan...@gmail.com

unread,
Feb 1, 2019, 2:13:14 PM2/1/19
to Keras-users
Did you solve this issue?
Reply all
Reply to author
Forward
0 new messages