我现在遇到了同样的问题。我无法完全激励为什么,但我相信它与Tensorflow和Keras之间的一些版本兼容性问题有关。刚刚改变导入删除了我的问题。
以下代码让我运行模型时出现错误(并且它到达第二个时代)
import os.path as op
import pandas as pd
import numpy as np
import tensorflow as tf
from keras.callbacks import ModelCheckpoint, TensorBoard
from keras.models import Sequential
from keras.layers import LSTM, Activation, Dense
from keras.utils.np_utils import to_categorical
import matplotlib.pyplot as plt
但如果我将它更改为
import os.path as op
import pandas as pd
import numpy as np
import tensorflow as tf
from tensorflow.keras.callbacks import ModelCheckpoint, TensorBoard
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import LSTM, Activation, Dense
from keras.utils.np_utils import to_categorical
import matplotlib.pyplot as plt
它按预期工作。我会假设我通过PIP安装的Keras版本(@ 987654323)与我安装的Tensorflow版本不兼容(tensorflow-gpu==1.10.0)。使用与tensorflow捆绑在一起的keras功能(tensorflow.keras)在我的情况下解决了它。