这是我的模特:
model = Sequential()
model.add(layers.Embedding(vocab_size, embedding_size, mask_zero=True, input_length = TO_BE_FOUND))
model.add(layers.LSTM(hidden_size, dropout=0.2, recurrent_dropout=0.2, return_sequences=True))
model.add(layers.TimeDistributed(layers.Dense(4, activation='softmax')))
model.compile(loss='categorical_crossentropy', optimizer='rmsprop', metrics=['acc'])
这是我的健身模特:
model.fit(train_x_padded, train_y_padded,batch_size=32, epochs=10, verbose=2,shuffle=True, validation_data=(train_x_padded, train_y_padded)
这是我得到的错误:
AlreadyExistsError Traceback (most recent call last) <ipython-input-24-109d4dab5962> in <module>() ----> 1 model.fit(train_x_padded, train_y_padded,batch_size=32, epochs=10, verbose=2,shuffle=True, validation_data=(train_x_padded, train_y_padded))
.
.
.
AlreadyExistsError: Resource __per_step_26/training_6/RMSprop/gradients/lstm_5/while/ReadVariableOp_4/Enter_grad/ArithmeticOptimizer/AddOpsRewrite_Add/tmp_var/N10tensorflow19TemporaryVariableOp6TmpVarE
[[{{node training_6/RMSprop/gradients/lstm_5/while/ReadVariableOp_4/Enter_grad/ArithmeticOptimizer/AddOpsRewrite_Add/tmp_var}}]]
答案 0 :(得分:0)
尝试从keras backend开始进行clear_session:
keras.backend.clear_session()
销毁当前的TF图并创建一个新的TF图。有助于避免旧模型/图层造成混乱。