Skip to content

Commit

Permalink
add task emb explanation
Browse files Browse the repository at this point in the history
  • Loading branch information
MorvanZhou committed Feb 22, 2021
1 parent 9e3252f commit 6ea9d56
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions GPT.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ def __init__(self, model_dim, max_len, n_layer, n_head, n_vocab, lr, max_seg=3,
self.n_vocab = n_vocab
self.max_len = max_len

# I think task emb is not necessary for pretraining,
# because the aim of all tasks is to train a universal sentence embedding
# the body encoder is the same across all tasks,
# and different output layer defines different task just like transfer learning.
# finetuning replaces output layer and leaves the body encoder unchanged.

# self.task_emb = keras.layers.Embedding(
# input_dim=n_task, output_dim=model_dim, # [n_task, dim]
# embeddings_initializer=tf.initializers.RandomNormal(0., 0.01),
# )

self.word_emb = keras.layers.Embedding(
input_dim=n_vocab, output_dim=model_dim, # [n_vocab, dim]
embeddings_initializer=tf.initializers.RandomNormal(0., 0.01),
Expand Down

0 comments on commit 6ea9d56

Please sign in to comment.