question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using pre-trained word embeddings

See original GitHub issue

I used pre-trained word embeddings to initialize the weights of query and document embeddings like below code.

pre_trained_vectors = np.fromfile(path).reshape([-1, dim])
query_embedding_column = tf.feature_column.embedding_column(
    ...,
    initializer=tf.compat.v1.constant_initializer(pre_trained_vectors))

As a result, the training converged faster and the metric of result was pretty improved. I think using pre-trained vectors seems to be quite useful.

But the training time has increased.

The reason is that the weights are initialized with every evaluations. It takes unnecessarily long, because it will be restored from checkpoint file. And the data of pre-trained vectors is saved to meta file unnecessarily.

I’d like to know the way of initializing weights only at the first time of training.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
xuanhuiwangcommented, Dec 3, 2019

@muik, feel free to send a PR to add scaffold to _RankingHead.

1reaction
muikcommented, Nov 28, 2019

Thank you for the related link. I tried to use tf.train.Scaffold for initializing weights like the answer of the link. But scaffold argument could be passed to tf.estimator.EstimatorSpec, because the code where EstimatorSpec is instantiated is wraped by _RankingHead class on ranking/head.py.

So I had to modify _RankingHead class on head.py file to pass the scaffold argument. Now the problem is solved.

In addition, It would be nice to provide a way of passing arguments to creating EstimatorSpec.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pretrained Word Embeddings | Word Embedding NLP
Pretrained word embeddings capture the semantic and syntactic meaning of a word as they are trained on large datasets. They are capable of ......
Read more >
Using pre-trained word embeddings - Keras
In this example, we show how to train a text classification model that uses pre-trained word embeddings. We'll work with the Newsgroup20 ...
Read more >
Guide to Using Pre-trained Word Embeddings in NLP
In this article, we'll take a look at how you can use pre-trained word embeddings to classify text with TensorFlow. Full code included....
Read more >
Using Pre-trained Word Embeddings - GluonNLP
Practitioners of deep learning for NLP typically initialize their models using pre-trained word embeddings, bringing in outside information, and reducing ...
Read more >
Pre-trained Word embedding using Glove in NLP models
Algorithm for word embedding: · Preprocess the text data. · Created the dictionary. · Traverse the glove file of a specific dimension and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found