Git Product home page Git Product logo

cs291k's Introduction

CS291K

Sentiment Analysis of Twitter data using a combined CNN-LSTM Neural Network model

Motivation

This project seeks to extend the work we did previously on sentiment analysis using simple Feed-Foward Neural Networks (Found here: paper & repo). Instead, we wish to experiment with building a combined CNN-LSTM Neural Net model using Tensorflow to perform sentiment analysis on Twitter data.

Dependencies

sudo -H pip install -r requirements.txt

Run the Code

  • On train.py change the variable MODEL_TO_RUN = {0 or 1}
    • 0 = CNN-LSTM
    • 1 = LSTM-CNN
  • Feel free to change other variables (batch_size, filter_size, etc...)
  • Run python train.py (or, with proper permissions, ./train.py

Code Structure

  • lstm_cnn.py : Contains the LSTM_CNN Model class to be instantiated.
  • cnn_lstm.py : Contains the CNN_LSTM Model class to be instantiated.
  • train.py : Main runner for the code. It instantiates a model, trains it and validates it.
  • batchgen.py : Contains a couple of functions needed to pre-process and tokenize the dataset.

cs291k's People

Contributors

pmsosa avatar

Stargazers

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

Watchers

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

cs291k's Issues

about dataset

I find those issues #6, #5, #4,#1. I find the file of glove.6b.50d.txt. But I do not find other three files. And I see that link about kaggle. When I open the link, the dataset "An error occurred: Data not found". So, can you offer these files for me? I hope you can share those files if you have. thanks,please!

dataset

我看了代码,发现good_tweets.csv和bad_tweets.csv是利用代码做出来的文件,所以我应该是需要batchgen.py代码里面的small.txt
image
目前我所看的代码不知道train.py里面的tweets.csv有没有用到,如果可以的话,能不能把small.txt 和tweets.csv文件发送给我?谢谢。

Error when use LSTM-CNN model.

Here is the traceback :

Traceback (most recent call last):
  File "train.py", line 143, in <module>
    model = LSTM_CNN(x_train.shape[1],y_train.shape[1],len(vocab_processor.vocabulary_),embedding_dim,filter_sizes,num_filters,l2_reg_lambda)
  File "/home/bishe/Workspace/lstm_cnn_original/lstm_cnn.py", line 39, in __init__
    conv = tf.nn.conv2d(self.lstm_out_expanded, W,strides=[1, 1, 1, 1],padding="VALID",name="conv")
  File "/home/bishe/.local/lib/python2.7/site-packages/tensorflow/python/ops/gen_nn_ops.py", line 639, in conv2d
    data_format=data_format, dilations=dilations, name=name)
  File "/home/bishe/.local/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
    op_def=op_def)
  File "/home/bishe/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 3162, in create_op
    compute_device=compute_device)
  File "/home/bishe/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 3208, in _create_op_helper
    set_shapes_for_outputs(op)
  File "/home/bishe/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2427, in set_shapes_for_outputs
    return _set_shapes_for_outputs(op)
  File "/home/bishe/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2400, in _set_shapes_for_outputs
    shapes = shape_func(op)
  File "/home/bishe/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2330, in call_with_requiring
    return call_cpp_shape_fn(op, require_shape_fn=True)
  File "/home/bishe/.local/lib/python2.7/site-packages/tensorflow/python/framework/common_shapes.py", line 627, in call_cpp_shape_fn
    require_shape_fn)
  File "/home/bishe/.local/lib/python2.7/site-packages/tensorflow/python/framework/common_shapes.py", line 691, in _call_cpp_shape_fn_impl
    raise ValueError(err.message)
ValueError: Negative dimension size caused by subtracting 50 from 32 for 'conv-maxpool-3/conv' (op: 'Conv2D') with input shapes: [?,50,32,1], [3,50,1,32].

What's wrong with it.

By the way, I use data in https://github.com/pmsosa/Twitter-Sentiment-Analysis/tree/master/data

Error: terminate called recursively; Aborted(core dumped)

After googling the error, i tried reducing batch size from 128 to 64 .. 8. No matter how many times I run, training goes fine but in evaluation I am getting this error in the beginning.

terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
terminate called recursively
Aborted(core dumped)

Any suggestions?

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.