Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: 'numpy.float64' object is not iterable Keras

The following line of code gives me the above error in Keras. model is a Graph model in Keras.

score, acc = model.evaluate({
    'input1': X_test1,
    'input2': X_test2,
    'output':Y_test}, batch_size=450)

but when I change it to the following, it runs fine.

predictions = model.predict({
    'input1': X_test1,
    'input2': X_test2}, batch_size=450)['output']

The Y_test here is a <type 'numpy.ndarray'> of <type 'numpy.ndarray'>. A one-hot encoded vector.

Sample Y_test:

[[1.,0.,0.],[1.,0.,0.],[0.,0.,1.]]
like image 556
a'- Avatar asked Apr 11 '16 18:04

a'-


1 Answers

As you can see here :

https://github.com/fchollet/keras/blob/master/keras/engine/training.py

The evaluate method returns only test loss (or losses). So assigning result of this method to a pair results in error.

like image 113
Marcin Możejko Avatar answered Nov 14 '22 22:11

Marcin Możejko