practical-machine-learning-with-python icon indicating copy to clipboard operation
practical-machine-learning-with-python copied to clipboard

Error in Accessing Layers of Word Embedding model

Open Anacoder1 opened this issue 6 years ago • 1 comments

In this code, in the "Get word embeddings" section of the "Skip-gram model", the code is as follows:

merge_layer = model.layers[0] word_model = merge_layer.layers[0] word_embed_layer = word_model.layers[0] weights = word_embed_layer.get_weights()[0][1:]

The above code gives the error as

AttributeError: 'InputLayer' object has no attribute 'layers'

The following code should be inserted in place of the above code (it works perfectly):

word_embed_layer = model.layers[2] weights = word_embed_layer.get_weights()[0][1:]

Anacoder1 avatar Sep 09 '19 05:09 Anacoder1

Thanks

Sinchit avatar Apr 14 '21 18:04 Sinchit