kyzhouhzau / BERT-NER

Use Google's BERT for named entity recognition (CoNLL-2003 as the dataset).
MIT License
1.24k stars 335 forks source link

Why `tf.train.init_from_checkpoint` in func `model_fn` run twice #40

Open icecity96 opened 5 years ago

icecity96 commented 5 years ago

In function model_fn:

        if init_checkpoint:
            (assignment_map, initialized_variable_names) = modeling.get_assignment_map_from_checkpoint(tvars,init_checkpoint)
            tf.train.init_from_checkpoint(init_checkpoint, assignment_map)
            if use_tpu:
                def tpu_scaffold():
                    tf.train.init_from_checkpoint(init_checkpoint, assignment_map)
                    return tf.train.Scaffold()
                scaffold_fn = tpu_scaffold
            else:
                tf.train.init_from_checkpoint(init_checkpoint, assignment_map)

why tf.train.init_from_checkpoint should run twice?

xiao2mo commented 5 years ago

The first init op can be omitted. I think the author leave it incautiously.