predict with Keras fails due to faulty environment setup

前端 未结 3 1129
慢半拍i
慢半拍i 2021-01-22 03:46

I can\'t get Keras to predict anything. Not even in this minimalistic model:

from keras.models import Sequential
from keras.layers import Dense
import numpy as np         


        
相关标签:
3条回答
  • 2021-01-22 04:36

    It turned out the code wasn't the problem, but there was something wrong with my software. After the following steps, the above code runs without errors or warnings:

    1. uninstall anaconda
    2. install anaconda
    3. create new environment
    4. install required packages into that environment (keras, tensorflow, spyder...)
    5. run code in that environment
    0 讨论(0)
  • 2021-01-22 04:40

    I pasted your code into https://colab.research.google.com and it didn't give me an error. (python2)

    I did however get a warning about int to float conversion.

    I would try to specify the test_input dtype explicitly as in:

    test_input = np.zeros((1,inDim), dtype=float)
    

    Since that seems to be the error message that is being output.

    0 讨论(0)
  • 2021-01-22 04:43

    I uninstalled and installed the Anaconda Navigator again and it got fixed.

    0 讨论(0)
提交回复
热议问题