UnboundLocalError: local variable 'batch_index' referenced before assignment

后端 未结 4 1087
清歌不尽
清歌不尽 2020-12-11 10:06

This is NOT MY code by here is the line, where it shows a problem:

model.fit(trainX, trainY, batch_size=2, epochs=200, verbose=2)

(As I am thinking now, it i

4条回答
  •  猫巷女王i
    2020-12-11 10:42

    The problem was resolved!

    I had to import the correct libraries (Tensorflow and not Keras directly):

    instead of importing directly Keras:

    from tensorflow.python import keras.models.Sequential
    from tensorflow.python import keras.layers.Dense
    

    importing of only tensorflow works:

    from tensorflow.python.keras.layers import Input, Dense
    from tensorflow.python.keras.models import Sequential
    

    Apparently this is related to the different version issue of Keras.

提交回复
热议问题