addons
addons copied to clipboard
crf_losses.py as in keras_contrib?
Hello, I want to ask if you there is an alternative crf_losses.py as in keras_contrib in tensorflow_addons?
Hi @afi1289,
I believe that we have a crf layer however we do not have an alternative for crf losses.
Thank you for your reply @Harsh188 Could you add crf_losses.py to losses, crf_accuracies.py to metrics? thats will help a lot (especially for beginners like me) by implementing BiLSTM-CRF models which initially implemented using keras-contrib. Thank you in advance!
Hi @Harsh188 , I agree with @afi1289 , please add them
You can check https://github.com/xuxingya/tf2crf
I don't know if @xuxingya Is interested to contribute here.
If you won't mind, I'd like to take a stab at this. I've found a repo which implements CRF Loss.
CRF Loss: https://github.com/howl-anderson/tf_crf_layer/blob/master/tf_crf_layer/loss/crf_loss.py CRF Accuracy: https://github.com/howl-anderson/tf_crf_layer/blob/master/tf_crf_layer/metrics/crf_accuracy.py
A bit of polish, and should make for a good PR, I suppose?
EDIT: More resources: https://github.com/mtreviso/linear-chain-crf
Okay, I did some research on this. Thing is, the loss function doesn't solely depend on y_true and y_pred but also the internal variables. So, we can't use eager tensor for y_pred(since keras.contrib uses _keras_history
to access internal variables, more at this issue: https://github.com/tensorflow/tensorflow/issues/37119
@afi1289 Further investigations revealed that, you could add a custom wrapper around our CRF class for loss as is shown here, sample tutorial here.
@afi1289 , can this be closed as part of #1999 ?
If you won't mind, I'd like to take a stab at this. I've found a repo which implements CRF Loss.
CRF Loss: https://github.com/howl-anderson/tf_crf_layer/blob/master/tf_crf_layer/loss/crf_loss.py CRF Accuracy: https://github.com/howl-anderson/tf_crf_layer/blob/master/tf_crf_layer/metrics/crf_accuracy.py
A bit of polish, and should make for a good PR, I suppose?
I am the author of this repo, and I happy to bring back the CRF accuracy feature to TFA. I will submit a PR for it when it is ready.
constraints
in the AllenNLP (https://docs.allennlp.org/main/api/modules/conditional_random_field/) is awesome feature too. It also exits in my repo (in a different branch). I hope I can bring it to the TFA in the future.
TensorFlow Addons is transitioning to a minimal maintenance and release mode. New features will not be added to this repository. For more information, please see our public messaging on this decision: TensorFlow Addons Wind Down
Please consider sending feature requests / contributions to other repositories in the TF community with a similar charters to TFA: Keras Keras-CV Keras-NLP