openai / generating-reviews-discovering-sentiment

Code for "Learning to Generate Reviews and Discovering Sentiment"
https://arxiv.org/abs/1704.01444
MIT License
1.51k stars 379 forks source link

Is the sentiment neuron at position 3159? #2

Closed aykutfirat closed 7 years ago

Newmu commented 7 years ago

2388 is the unit visualized and the single experiment results are reported on in the paper

bitliner commented 7 years ago

Extracting the 2388-th does not work for me. I always get 0 as value.

I used examples that are predicted as positive in the paper.

Example:

if __name__ == '__main__':
    mdl = Model()
    text = [
        'too bad!', 
        'it was so cool, beautiful', 
        'the screenplay and the directing were horrendous', 
        'best books'
    ]
    text_features = mdl.transform(text)
    print('shape')
    print(text_features.shape)
    sentiment = text_features[:, 2388]
    print('sentiment')
    print(sentiment)

Result:

0.000 seconds to transform 4 examples
shape
(4, 4096)
sentiment
[ 0.  0.  0.  0.]

Apparently I get 0. for every value of the feature vector extracted, there must be an error somewhere else I guess, looking for it.

dthiagarajan commented 7 years ago

Referenced in #3 - it's something to do with how HTMLParser.HTMLParser().unescape(text) works. I ran into the same problem trying it with Python 2, but wasn't able to resolve it.