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

it is right? sum(text_features) #18

Closed zhaoyingjun closed 7 years ago

zhaoyingjun commented 7 years ago

from encoder import Model import matplotlib.pyplot as plt import numpy as np model=Model() text = ['horrendous','good','fuck','nice','well','bad','face','me'] text_features = model.transform(text) for i in range(len(text)): t = np.sum(text_features[i]) print(text[i],t)

but the result: 12.180 seconds to transform 8 examples horrendous -18.1347 good -35.834 fuck -15.2731 nice -26.8903 well -7.1143 bad -17.0147 face -2.13978 me 4.94617

Newmu commented 7 years ago

model.transform() returns features, not sentiment scores. The sentiment unit discussed in the paper is index 2388 so t = text_features[2388] may return sensible results. The model has not been tested on pieces of text shorter than phrases however, so I'm not sure what to expect from single words in isolation.