In keras Sequential model, one can set weight directly using set_weights
method.
model.layers[n].set_weights([your_wight])
However I am facing problem if I am trying to set weight to a layer using functional API.
Here is the code snippet:
emb = Embedding(max_words, embedding_dim, input_length=maxlen)(merge_ip)
#skipping some lines
.
.
emb.set_weights([some_weight_matrix])
This is throwing error that
AttributeError: 'Tensor' object has no attribute 'set_weights'
which I think becouse emb
is a Tensor object.
I am wondering how to set wight properly in my model