import numpy
......
# Prediction
predictions = model.predict(X_test)
# round predictions
rounded = [round(x) for x in predictions]
print(rounded)
\"predictions\"
I encountered the same error when I was trying the tutorial of Keras.
At first, I tried
rounded = [numpy.round(x) for x in predictions]
but it showed the result like this:
[array([1.], dtype=float32), array([0.],dtype=float32), ...]
then I tried this:
rounded = [float(numpy.round(x)) for x in predictions]
it showed the right outputs.
I think the "numpy.round(x)" returns list of ndarray, and contains the dtype parameter. but the outputs are correct with the value. So converting each element of the list to float type will show the right outputs as same as the tutorial.
My machine is Linux Mint 17.3(ubuntu 14.04) x64, and python interpreter is python 3.5.2, anaconda3(4.1.1), numpy 1.11.2