Skip to content
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

Almost constant gates values. #1

Open
mojesty opened this issue Oct 20, 2018 · 2 comments
Open

Almost constant gates values. #1

mojesty opened this issue Oct 20, 2018 · 2 comments

Comments

@mojesty
Copy link

mojesty commented Oct 20, 2018

Hello. I use python2.7 and PyTorch 0.3.1/0.3.0, when I run the following code:

sens = 'i like orange apples .'
words = sens.strip().split()
x = numpy.array([corpus.dictionary[w] for w in words])
input = Variable(torch.LongTensor(x[:, None]))

hidden = model.init_hidden(1)
_, hidden = model(input, hidden)

gates = model.gates.squeeze().data.numpy()

i receive the wollowing gates activations:
array([0.07, 0.07, 0.07, 0.07, 0.06], dtype=float32)
so the parse tree is built incorrectly.
The inputs look like this:
array([3277, 262, 35, 3339, 11])
It works the same on different sentences/different versions of PyTorch (I tried 0.3.0 and 0.3.1, on 0.4.1 code fails to work because of changed BatchNorm1D ), and always most of gates has value 0.07 and parse trees look like they are incorrect.
Please explain to me what am i doing wrong.

@phu-pmh
Copy link
Member

phu-pmh commented Oct 21, 2018

Are you training the model on your own? Which version of the model is this?
In any case, the following is my result using our best model:

Input array: array([ 8336,  6795, 18385,  3176,   373])
Output gates: array([ 0.27,  0.13,  0.02,  0.13,  0.17], dtype=float32))  
Tree: ( i ( ( ( like orange ) apples ) . ) )

It seems like we are using different dictionary for input tokens.
I did not make any modification to the code of Shen et al 2018 so I'm afraid I have little idea what could be wrong after some modifications to the original code.

@mojesty
Copy link
Author

mojesty commented Oct 21, 2018

I used your pretrained model and I simply ran the code that build vocabulary corpus = data.Corpus(args.data). I did not make any modifications to the original code, simply ran it.
Which version of PyTorch do you have?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants