1
我有幾個使用Keras構建的神經網絡,目前我主要使用Jupyter。我經常使用json + hdf5與joblib和Keras一起保存scikit-learn的模型,並在其他筆記本中毫無問題地使用它們。使用Keras序列化模型在pyspark中退出
我做了一個Python Spark應用程序,可以在羣集模式下使用這些序列化的模型。 joblib模型正常工作,但是,我遇到了Keras的問題。
這裏是筆記本電腦和pyspark使用的模型:
def build_gru_model():
model = Sequential()
model.add(Embedding(max_nb_words, 128, input_length=max_sequence_length, dropout=0.2))
model.add(GRU(128, dropout_W=0.2, dropout_U=0.2))
model.add(Dense(2, activation='softmax'))
model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
return model
都呼籲以同樣的方式:
preds = model.predict_proba(data, verbose=0)
然而,只有在星火我得到的錯誤:
MissingInputError: ("An input of the graph, used to compute DimShuffle{x,x,x,x}(keras_learning_phase), was not provided and not given a value.Use the Theano flag exception_verbosity='high',for more information on this error.", keras_learning_phase)
我已經完成了必須的搜索並找到了:https://github.com/fchollet/keras/issues/2430其中指向https://keras.io/getting-started/faq/
如果我真的從我的模型中刪除丟失,它的工作原理。但是,我不明白如何實施一些能夠讓我在培訓階段保持退出的方式,如常見問題中所述。
根據型號代碼,如何完成此操作?
有了一個快速的測試,它似乎確實做的伎倆!不能相信這是如此簡單,謝謝! :)讓我試試訓練模型再次輟學明天 – Gaarv
與輟學工作完美,謝謝! – Gaarv