Graph problems Tutorial 1


I try to make Tutorial 1 work in colab, and faced some problems.
Most of them (somehow :)) solved, but right now i faced with error:
“tensor %s is not an element of this graph” about last layer of my network.

This is the shared link to the notebook:

Can you, please, help me or give some advise to solve this?

P.S. i’ve changed part of the code in training part to make sure that i can go to interact model.

Forgot to mark.
This block causes error:

x_valid, y_valid = iterator.get_instances(data_type="valid") best_score = 0 patience = 2 impatience = 0

for ep in range(10):
for x, y in iterator.gen_batches(batch_size=64,
data_type=“train”, shuffle=True):
x_embed = embedder(tokenizer(preprocessor(x)))
y_onehot = one_hotter(vocab(y))
model.train_on_batch(x_embed, y_onehot)
global graph
with graph.as_default():
y_valid_pred = model(embedder(tokenizer(preprocessor(x_valid))))
score = sets_accuracy(y_valid, vocab(prob2labels(y_valid_pred)))
print(“Epochs done: {}. Valid Accuracy: {}”.format(ep + 1, score))
if score > best_score:
print(“New best score. Saving model.”)
best_score = score
impatience = 0
impatience += 1
if impatience == patience:
print(“Out of patience. Stop training.”)


Sorry for delayed answer. It seems we have broken previously working graph compatibility for Keras (this bug doesn’t appear when using training/infering with command line).
We are gonna fix it in the next release. For now, you can simply use deeppavlov==0.7 version. By the way this version doesn’t contain str_lower preprocessor, so use another one or do simple lower-casing by hands.

Thank you for reporting this issue.