Skip to content
This repository has been archived by the owner on Nov 3, 2022. It is now read-only.

CRF for keras 2.x #76

Merged
merged 8 commits into from
May 18, 2017
Merged

Conversation

linxihui
Copy link
Contributor

@linxihui linxihui commented Apr 21, 2017

An Implementation of linear chain conditional random field (CRF), modified for keras 2.0 from previous PR keras-team/keras#4646

Note this PR has #79 merged. Please merged.

@linxihui
Copy link
Contributor Author

linxihui commented Apr 24, 2017

@farizrahman4u The tensorflow and keras version are not compatible in .travis checking.
The tensorflow version is 0.12.1. It has two concatenate functions tf.concat(axis, tensors) and tf.concat_v2(tensors, axis). However, in keras tensorflow backend, K.concatenate(tensors, axis) = tf.concat(tensors, axis). In tensorflow 1.x, tf.concat is changed to accept tensors as 1st argument. This is the reason the CRF checking fail.

I think tensorflow should be update to version 1.x in .travis.

@farizrahman4u
Copy link
Contributor

@linxihui Thanks for pointing it out.. please submit a PR to fix travis config so that you get the Github credits.

@farizrahman4u
Copy link
Contributor

Cool stuff! Can anyone review?

Copy link
Collaborator

@tboquet tboquet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! When the comment will be addressed, I'll try to test the example before approving the changes. We could maybe reference #25, a parallel PR.

return acc

@staticmethod
def log_sum_exp(x, axis=-1):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since keras-team/keras#6346 has been merged, could it be integrated in this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, will change it soon.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it is merged fairly recently, but people who not using the master branch (e.g., install using pip) will have trouble. So I keep it. Maybe remove it sometime later.

Copy link
Collaborator

@tboquet tboquet May 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok let's keep this in mind and open an issue linked to this PR to make sure we make the change when this will be merged?

Copy link
Contributor Author

@linxihui linxihui May 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then I probably should just change it. Actually, there is a bug when using K.logsumexp with tensorflowbackend, when passed a placeholder, it losses the shape information, i.e.,K.int_shapegot None. This is due to the fact thatK.logsumexpuses an deprecidated argument. I'll make a PR tokeras` and will make the change here one it is merged.
See keras-team/keras#6516


import numpy
from collections import Counter
from sklearn.metrics import classification_report
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we try to avoid those dependencies (sklearn and nltk)?
I agree this is very convenient and not hard to install but it could be easy to add a new dataset as in #25.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sklearn is not necessary, as I just use the classification_report to print the result in a nice way. nltk is here for getting the data. My original idea was a bit on the opposite, avoiding having the same dataset in multiple packages or writing duplicate script to load data, but instead using an existing package, which also saves the effort of licensing. But I understand the disadvantage as well. I'll change it, as it probably fits better to the Keras way.

@linxihui
Copy link
Contributor Author

linxihui commented May 5, 2017

@tboquet using K.logsumexp now.

@linxihui
Copy link
Contributor Author

@tboquet @farizrahman4u any one do the code review?

@farizrahman4u
Copy link
Contributor

LGTM, need confirmation from one more moderator.

Copy link
Collaborator

@tboquet tboquet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@the-moliver the-moliver merged commit d1f4b6b into keras-team:master May 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants