HDU 2057 A + B Again(16进制加法)
1039
2022-08-23
TypeError Expected int32 got tensorflow python ops variables Variable object at 0x117ea3a10 of t
今天在运行别人的demo程序的时候,发现了一个错误,百思不得其解,明明没干啥,运行别人的demo也出错,我的错误信息为
Traceback (most recent call last): File "model.py", line 23, in
我的代码为:
# LSTM for sequence classification in the IMDB datasetimport numpyfrom keras.datasets import imdbfrom keras.models import Sequentialfrom keras.layers import Densefrom keras.layers import LSTMfrom keras.layers.embeddings import Embeddingfrom keras.preprocessing import sequence# fix random seed for reproducibilitynumpy.random.seed(7)# load the dataset but only keep the top n words, zero the resttop_words = 5000(X_train, y_train), (X_test, y_test) = imdb.load_data(nb_words=top_words)# truncate and pad input sequencesmax_review_length = 500X_train = sequence.pad_sequences(X_train, maxlen=max_review_length)X_test = sequence.pad_sequences(X_test, maxlen=max_review_length)# create the modelembedding_vecor_length = 32model = Sequential()model.add(Embedding(top_words, embedding_vecor_length, input_length=max_review_length))model.add(LSTM(100))model.add(Dense(1, activation='sigmoid'))model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])print(model.summary())model.fit(X_train, y_train, nb_epoch=3, batch_size=64)# Final evaluation of the modelscores = model.evaluate(X_test, y_test, verbose=0)print("Accuracy: %.2f%%" % (scores[1]*100))
环境为
mac keras 1.2.2 tensorflow (1.0.1)
解决方法:
pip install keras --upgrade
升级到2.1.2,然后就运行成功了。
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~