我在tensorflow集线器中查看ELMo模型,我不太清楚tokens_length = 6,5在流示例中的含义是什么:(https://tfhub.dev/google/elmo/2)
elmo = hub.Module("https://tfhub.dev/google/elmo/2", trainable=True)
tokens_input = [["the", "cat", "is", "on", "the", "mat"],
["dogs", "are", "in", "the", "fog", ""]]
tokens_length = [6, 5]
embeddings = elmo(
inputs={
"tokens": tokens_input,
"sequence_len": tokens_length
},
signature="tokens",
as_dict=True)["elmo"]它不喜欢输入标记句的最大长度,不喜欢每个句子的最大字数,也不喜欢句子的数目,这让我很困惑。有人能解释一下吗?谢谢!
发布于 2019-06-25 12:38:14
第一个示例的长度为6,第二个示例的长度为5:。即
“猫在席上”有六个字长,“狗在雾中”只有五个字长。输入中的额外空字符串确实增加了一些混乱:-/
如果您阅读该页面上的文档,就会解释为什么需要这样做(粗体字体是我的)。
使用令牌签名,模块将标记化的句子作为输入。输入张量是batch_size、max_length的字符串张量和与句子长度相对应的batch_size形的int32张量。长度的输入是必要的,以排除填充在句子的变化长度。
https://stackoverflow.com/questions/56754041
复制相似问题