Keras: "trainable" parameter is not available in Embedding layer of Keras 2.0

Created on 30 Jan 2018  路  3Comments  路  Source: keras-team/keras

I am loading the pre-trained embedding in my network with the following code:

qe = Embedding(input_dim=10, output_dim=20, trainable=False, mask_zero=True, weights=[weights], name='qe' )(question)

When I compile this model with keras version 1.1.0, no of parameters for this layer are 0, while when I compile the same code with keras version 2.0, no of parameters are non zero. This made me believe that "trainable" parameter is not working as intended.

So I looked into the documentation and code (https://keras.io/layers/embeddings/), and realized that "trainable" parameter is being removed in the newer version of Keras.

Could someone please help to make the embedding layer non-trainable in keras 2.0 version ?

Most helpful comment

The trainable parameter works but is missing from the documentation (as well as from code-completion suggestions). Its addition to the documentation might improve clarity and prevent questions like the one in this issue.

All 3 comments

Can you provide a standalone snippet of code so that I can reproduce this issue? Thanks.

set qe.trainable=False, this will render the layer not trainable

The trainable parameter works but is missing from the documentation (as well as from code-completion suggestions). Its addition to the documentation might improve clarity and prevent questions like the one in this issue.

Was this page helpful?
0 / 5 - 0 ratings