是否可以像在 tensorflow 中那样在 keras 中创建可训练变量?
Is it possible to create a trainable variable in keras like in tensorflow?
大家早上好;
我正在尝试实施 this model where the neural network's inputs are based on a trainable vocabulary matrix (each row in the matrix represents a word entry in the vocabulary). I'm using keras (tensorflow backend), I was wondering if it's possible to define a trainable variable (without adding a custom layer), such that this variable will be trained as well as the neural network? like a tensorflow variable。
你能举一个简短的例子说明我该怎么做吗?
提前致谢。
The neural network's inputs are based on a trainable vocabulary matrix (each row in the matrix represents a word entry in the vocabulary)
这是一个Word Embedding
的定义
Keras 中已有 embedding layer,您不必重新实现它。
您可以找到有关如何使用它的简单示例 here。
大家早上好; 我正在尝试实施 this model where the neural network's inputs are based on a trainable vocabulary matrix (each row in the matrix represents a word entry in the vocabulary). I'm using keras (tensorflow backend), I was wondering if it's possible to define a trainable variable (without adding a custom layer), such that this variable will be trained as well as the neural network? like a tensorflow variable。 你能举一个简短的例子说明我该怎么做吗? 提前致谢。
The neural network's inputs are based on a trainable vocabulary matrix (each row in the matrix represents a word entry in the vocabulary)
这是一个Word Embedding
Keras 中已有 embedding layer,您不必重新实现它。
您可以找到有关如何使用它的简单示例 here。