-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can I access parameters of a node in nngraph #131
Comments
Hi,
Hence you just need to call the method parameters (or Try: require 'nn'
require 'rnn'
require 'nngraph'
nIndex1 = 20
embeddingSize = 128
nIndex2 = 30
input1 = nn.Identity()()
input2 = nn.Identity()()
embed1 = nn.LookupTableMaskZero(nIndex1, embeddingSize)(input1)
embed2 = nn.LookupTableMaskZero(nIndex2, embeddingSize)(input2)
madd = nn.CAddTable()({embed1, embed2})
madd_t = nn.SplitTable(2)(madd)
embed = nn.gModule({input1, input2}, {madd_t})
print(embed:parameters()) The output is:
The first table is weights, and the second is the gradient of weights, accordingly. Hope this help! |
I believe you can assess it using embed1.data.module.weight |
how to copy particular layer's weights from pretrained nn.Sequential model to nngraph's particular module? |
@brisker I'm dealing with same problem and I'm thinking of annotating the layer that I want to check/initialize its weights and biases. |
If you want to check/initialize parameters of a specific layer, If you see the code below, I've gave name to the batch normalization layer as 'BN_1' and initialized the parameters and biases of that layer.
|
how can I add only weights and bias term in the neural net graph? |
Hello!
I am creating an nngraph which combines two embeddings together. One of the embeddings is a word embedding and the other is not. For the word embedding, I would like to initialize its weights with the pre-trained word2vec. Is there a way to do so?
My nngraph looks like the following:
input1 = nn.Identity()()
input2 = nn.Identity()()
embed1 = nn.LookupTableMaskZero(nIndex1, embeddingSize)(input1)
embed2 = nn.LookupTableMaskZero(nIndex2, embeddingSize)(input2)
madd = nn.CAddTable()({embed1, embed2})
madd_t = nn.SplitTable(2)(madd)
embed = nn.gModule({input1, input2}, {madd_t})
Could you suggest a way to, say, set embed1.weight to pretrained word2vec?
Thank you!
The text was updated successfully, but these errors were encountered: