Giter Site home page Giter Site logo

clairett / deep-memory-network Goto Github PK

View Code? Open in Web Editor NEW
15.0 4.0 10.0 225 KB

Implement deep memory network used for Aspect Level Sentiment Classification

Python 100.00%
deep-memory-network aspect-sentiment sentiment semeval2015 aspect absa memory-network

deep-memory-network's Introduction

Aspect Level Sentiment Classification with Deep Memory Network

TensorFlow implementation of Tang et al.'s EMNLP 2016 work.

Problem Statement

Given a sentence and an aspect occurring in the sentence, this task aims at inferring the sentiment polarity (e.g. positive, negative, neutral) of the aspect.

Example

For example, in sentence ''great food but the service was dreadful!'', the sentiment polarity of aspect ''food'' is positive while the polarity of aspect ''service'' is negative.

Quick Start

Install this quick GLOVE embeddings loading tool

Runs on python3 and tensorflow 1.4.1

Train a model with 3 hops on the Restaurant dataset.

python main.py --show True

Performance

Achieved accuracy of 72% for Laptop and 79% for Restaurant.

Acknowledgements

  • More than 80% of the code is borrowed from ganeshjawahar.
  • Using this code means you have read and accepted the copyrights set by the dataset providers.

Author

Tian Tian

Licence

MIT

deep-memory-network's People

Contributors

clairett avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

deep-memory-network's Issues

AttributeError: 'array.array' object has no attribute 'tobytes'

Thanks for sharing the code,
I am using python 2, got this error:
using coding utf-8, otherwise will got another coding error.

import sys

reload(sys)
sys.setdefaultencoding('utf8')

(deepMemNet) zchen@hdp-node11:~/Deep-Memory-Network$ python main.py --show True
/home/zchen/anaconda2/lib/python2.7/site-packages/h5py/init.py:36: FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type.
from ._conv import register_converters as _register_converters
0%| | 778/2195895 [00:00<09:25, 3885.03it/s]Traceback (most recent call last):
File "main.py", line 73, in
tf.app.run()
File "/home/zchen/anaconda2/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 124, in run
_sys.exit(main(argv))
File "main.py", line 46, in main
embeddings = init_word_embeddings(FLAGS.pretrain_embeddings, word_set, FLAGS.edim)
File "/home/zchen/Deep-Memory-Network/data.py", line 16, in init_word_embeddings
embedding = GloveEmbedding(tokens[1], d_emb=edim, show_progress=True)
File "/home/zchen/anaconda2/lib/python2.7/site-packages/embeddings/glove.py", line 48, in init
self.load_word2emb(show_progress=show_progress)
File "/home/zchen/anaconda2/lib/python2.7/site-packages/embeddings/glove.py", line 81, in load_word2emb
self.insert_batch(batch)
File "/home/zchen/anaconda2/lib/python2.7/site-packages/embeddings/embedding.py", line 139, in insert_batch
binarized = [(word, array('f', emb).tobytes()) for word, emb in batch]
AttributeError: 'array.array' object has no attribute 'tobytes'
Exception KeyError: KeyError(<weakref at 0x7f70f9d98b50; to 'tqdm' at 0x7f70f9cc1c10>,) in <bound method tqdm.del of 0%| | 778/2195895 [00:00<24:56, 1467.16it/s]> ignored

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.