Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] model load, then fit (re-train), error of layer_crf #244

CoSeCant-csc opened this issue Sep 20, 2019 · 1 comment

[BUG] model load, then fit (re-train), error of layer_crf #244

CoSeCant-csc opened this issue Sep 20, 2019 · 1 comment


Copy link

@CoSeCant-csc CoSeCant-csc commented Sep 20, 2019

You must follow the issue template and provide as much information as possible. otherwise, this issue will be closed.
请按照 issue 模板要求填写信息。如果没有按照 issue 模板填写,将会忽略并关闭这个 issue

Check List

Thanks for considering to open an issue. Before you submit your issue, please confirm these boxes are checked.

You can post pictures, but if specific text or code is required to reproduce the issue, please provide the text in a plain text format for easy copy/paste.


  • OS [e.g. Mac OS, Linux]: Linux, Ubuntu 18.04
  • Python Version: 3.6
  • requirements.txt: tf-gpu==1.14.0
[Paste requirements.txt file here]

Issue Description


Hi, I have trained a model (BiLSTM_CRF_Model).
But when reload the mode, and do re-train, there is an error like this
Does anyone have ideas

model = kashgari.utils.load_model(READ_MODEL_PATH)
model.compile_model(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
model.fit_without_generator(train_x, train_y,

File "/home/userroot/.local/lib/python3.6/site-packages/kashgari/tasks/", line 345, in fit_without_generator
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/", line 780, in fit
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/", line 157, in model_iteration
f = _make_execution_function(model, mode)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/", line 532, in _make_execution_function
return model._make_execution_function(mode)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/", line 2276, in _make_execution_function
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/", line 2219, in _make_train_function
params=self._collected_trainable_weights, loss=self.total_loss)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/optimizer_v2/", line 491, in get_updates
grads = self.get_gradients(loss, params)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/optimizer_v2/", line 398, in get_gradients
"K.argmax, K.round, K.eval.".format(param))

ValueError: Variable <tf.Variable 'layer_crf/transitions:0' shape=(6, 6) dtype=float32> has None for gradient. Please make sure that all of your ops have a gradient defined (i.e. are differentiable). Common ops without gradient: K.argmax, K.round, K.eval.


[The steps to reproduce this issue. What is the URL you were trying to play, where did you put your code, etc.]

Other Comment

[Add anything else here]

@CoSeCant-csc CoSeCant-csc added the bug label Sep 20, 2019
@BrikerMan BrikerMan added this to the v0.5.4 milestone Sep 20, 2019

This comment has been minimized.

Copy link

@BrikerMan BrikerMan commented Sep 20, 2019

This is a confirmed bug, will fix in 0.5.4 version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.