nlp
tongk手势舞
硕士:福州大学
展开
-
nlp 分词 构建词表
MAX_VOCAB_SIZE = 10000UNK, PAD = '<UNK>', '<PAD>'def build_vocab(file_name, tokenize, max_size, min_freq): vocab_dic = {} with open(file_name, 'r', encoding='utf-8') as f: for line in f: lin = line.strip() .原创 2021-09-22 10:18:50 · 1097 阅读 · 0 评论 -
pytorch torch.nn.embedding
Embedding 模块作用:将词的索引转化为词对应的词向量,需要我们设置的两个参数:词汇表的大小和词嵌入的维度。num_embeddings (int): size of the dictionary of embeddingsembedding_dim (int): the size of each embedding vectorimport torch.nn as nnimport torchembedding = nn.Embedding(10, 3)string = 'hell原创 2021-09-22 09:22:44 · 349 阅读 · 0 评论