keras嵌入层构建 我是安得烈NG教授的序列模型班。这里我们正在构建嵌入层,如下所示 # Define Keras embedding layer with the correct output/input sizes, make it non-trainable. Use Embedding(...). Make sure to set trainable=False. embedding_layer = Embedding(vocab_len, emb_dim, trainable = False) # Build the embedding layer, it is required before setting the weights of the embedding layer. Do not modify the "None". embedding_layer.build((None,))

keras嵌入层构建 我是安得烈NG教授的序列模型班。这里我们正在构建嵌入层,如下所示 # Define Keras embedding layer with the correct output/input sizes, make it non-trainable. Use Embedding(...). Make sure to set trainable=False. embedding_layer = Embedding(vocab_len, emb_dim, trainable = False) # Build the embedding layer, it is required before setting the weights of the embedding layer. Do not modify the "None". embedding_layer.build((None,)),keras,time-series,Keras,Time Series,我很难理解构建方法。下面的函数正在添加什么。我找不到构建API。有关此API的参考资料将非常有用 构建嵌入层,需要在设置嵌入层权重之前进行。不要修改“无” 嵌入_layer.build((无,)) 谢谢通常,不需要自己在层上调用build() 只有当您在所描述的层上写入时,您才会关心它。 在那里,build是必需的方法之一。您可以使用它来定义层的权重。在最终模型上调用model.compile()时,这将在内部调用每个层的build()方法,并将上一层的输出形状传递给它 因此,在设置嵌入层的权重

我很难理解构建方法。下面的函数正在添加什么。我找不到构建API。有关此API的参考资料将非常有用

构建嵌入层,需要在设置嵌入层权重之前进行。不要修改“无”

嵌入_layer.build((无,))


谢谢

通常,不需要自己在层上调用
build()

只有当您在所描述的层上写入时,您才会关心它。 在那里,
build
是必需的方法之一。您可以使用它来定义层的权重。在最终模型上调用
model.compile()
时,这将在内部调用每个层的
build()
方法,并将上一层的输出形状传递给它

因此,在设置嵌入层的权重之前需要的注释
实际上是正确的:为了设置权重,层需要知道调用
build()
将告诉它的正确形状。但是,这并不意味着您必须自己调用
build()
。还可以在编译模型后设置权重

因此,总之,除非您的代码做了任何花哨的事情(我不知道,因为您没有进一步发布任何东西),否则对
build
的调用是过时的