guillaumegenthial / tf_ner

Simple and Efficient Tensorflow implementations of NER models with tf.estimator and tf.data
Apache License 2.0
923 stars 275 forks source link

Support for TF 2.0 #60

Open SivamPillai opened 5 years ago

SivamPillai commented 5 years ago

Hi,

Are there any plan to upgrade the library to support TF 2.0? I feel some of the new features can help simplify the code library and may also improve performance.

Thanks, Sivam.

Romaixn commented 3 years ago

+1 That would be cool! And the library could work like this, for the moment tf.contrib doesn't exist

xavierad commented 3 years ago

I solved it by using:

    # vocab_words = tf.contrib.lookup.index_table_from_file(
    #     params['words'], num_oov_buckets=params['num_oov_buckets'])
    num_oov_buckets = params['num_oov_buckets']
    vocab_words = tf.lookup.StaticVocabularyTable(
        tf.lookup.TextFileInitializer(
            params['words'],
            key_dtype=tf.string, key_index=tf.lookup.TextFileIndex.WHOLE_LINE,
            value_dtype=tf.int64, value_index=tf.lookup.TextFileIndex.LINE_NUMBER,
            delimiter="\t"),
        num_oov_buckets)

    # vocab_chars = tf.contrib.lookup.index_table_from_file(
    #     params['chars'], num_oov_buckets=params['num_oov_buckets'])
    vocab_chars = tf.lookup.StaticVocabularyTable(
        tf.lookup.TextFileInitializer(
            params['chars'],
            key_dtype=tf.string, key_index=tf.lookup.TextFileIndex.WHOLE_LINE,
            value_dtype=tf.int64, value_index=tf.lookup.TextFileIndex.LINE_NUMBER,
            delimiter="\t"),
        num_oov_buckets)
JamesPiggott commented 2 years ago

Dear xavierad, I cannot imagine that that is the only alteration you made. I get error messages that LSTMBlockFusedCell is no longer supported with TF 2.0 which is confirmed online.

xavierad commented 2 years ago

Yes. I just copied the class code to local. Tensorflow sucks

JamesPiggott commented 2 years ago

Interesting, could you push those changes to your fork?

iprovalo commented 6 months ago

Here is my fork with TF2 implementation of one of the models:

https://github.com/iprovalo/tf_ner/tree/master/models/chars_conv_lstm_crf_tf2