Tuesday, 26 November 2019

tensorflow_hub to pull BERT embedding on windows machine

I would like to get BERT embedding using tensorflow hub. I found it very easy to get ELMO embedding and my steps are below. Could anyone explain how to get BERT embedding on a windows machine? I found this but couldn't get it work on windows machine

  1. https://tfhub.dev/google/elmo/3 go to this link and then download.

  2. Unzip it twice till you see "tfhub_module.pb", provide path of that folder to get embedding

        import tensorflow as tf
        import tensorflow_hub as hub
    
        elmo = hub.Module("C:/Users/nnnn/Desktop/BERT/elmo/3.tar/3", trainable=True)
    
        with tf.Session() as sess:
            sess.run(tf.global_variables_initializer())
            abc1=sess.run(elmo(x, signature="default", as_dict=True)["default"])
    


from tensorflow_hub to pull BERT embedding on windows machine

No comments:

Post a Comment