더북(TheBook)
class Model_LSTM(nn.Module):
    def __init__(self, embedding_matrix, num_sub_targets):
        super(Model, self).__init__()
        self.embedding = Embedding(embedding_matrix)
        self.encoder = Encoder(num_sub_targets)
    def forward(self, x):
        x = self.embedding(x)
        out = self.encoder(x)
        return out

crawl_matrix, unknown_words_crawl = build_matrix(
    tokenizer.word_index, CRAWL_EMBEDDING_PATH
)
glove_matrix, unknown_words_glove = build_matrix(
    tokenizer.word_index, GLOVE_EMBEDDING_PATH
)

>>> print("n unknown words (crawl): ", len(unknown_words_crawl))
>>> print("n unknown words (glove): ", len(unknown_words_glove))
n unknown words (crawl):  140854
n unknown words (glove):  143012

embedding_matrix = np.concatenate([crawl_matrix, glove_matrix], axis=-1)
>>> print(embedding_matrix.shape)
(416731, 600)
신간 소식 구독하기
뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.