关于LSTM跑不动呀
x = LSTM(128, dropout=0.5)(embedded_sequences)
总是会报错: Cannot convert a symbolic Tensor (lstm_10/strided_slice:0) to a numpy array. This error may indicate that you’re trying to pass a Tensor to a NumPy call, which is not supported 因为说是tensorflow和numpy的兼容问题,所以我卸载重安装了好几次,直接给爷整麻了。 目前我的python是3.9,tensorflow=2.5.0,keras=2.4.3,python=1.19.2,可以通过cmd输入pip list 查找
此时有些安装包在直接通过keras安装时仍然会报错,例如:
from keras import backend as K
from keras import Model
from keras import Sequential
from keras.preprocessing.text import Tokenizer
module ‘keras.utils.generic_utils’ has no attribute ‘populate_dict_with_module_objects’ 可以通过在“keras”前面添加“tensorflow.”来完成:
from tensorflow.keras import backend as K
from tensorflow.keras import Model
from tensorflow.keras import Sequential
from tensorflow.keras.preprocessing.text import Tokenizer
|