lstm

Understanding LSTM model using tensorflow for sentiment analysis

懵懂的女人 提交于 2019-12-23 06:58:08
问题 I am trying to learn LSTM model for sentiment analysis using Tensorflow, I have gone through the LSTM model. Following code (create_sentiment_featuresets.py) generates the lexicon from 5000 positive sentences and 5000 negative sentences . import nltk from nltk.tokenize import word_tokenize import numpy as np import random from collections import Counter from nltk.stem import WordNetLemmatizer lemmatizer = WordNetLemmatizer() def create_lexicon(pos, neg): lexicon = [] with open(pos, 'r') as f:

Setting up the input on an RNN in Keras

十年热恋 提交于 2019-12-23 04:29:12
问题 So I had a specific question with setting up the input in Keras. I understand that the sequence length refers to the window length of the longest sequence that you are looking to model with the rest being padded by 0's. However, how do I set up something that is already in a time series array? For example, right now I have an array that is 550k x 28. So there are 550k rows each with 28 columns (27 features and 1 target). Do I have to manually split the array into (550k- sequence length)

Setting up the input on an RNN in Keras

主宰稳场 提交于 2019-12-23 04:29:08
问题 So I had a specific question with setting up the input in Keras. I understand that the sequence length refers to the window length of the longest sequence that you are looking to model with the rest being padded by 0's. However, how do I set up something that is already in a time series array? For example, right now I have an array that is 550k x 28. So there are 550k rows each with 28 columns (27 features and 1 target). Do I have to manually split the array into (550k- sequence length)

AttributeError: 'NoneType' object has no attribute 'update'

痞子三分冷 提交于 2019-12-23 04:23:35
问题 I am using keras to run bi-LSTM to do sentiment analysis in python, however, python gives me the error message: 'NoneType' object has no attribute 'update'. I searched on website however this problem still can't be solved. here is my code: import numpy as np import pickle as pk from keras.utils import np_utils from sklearn.preprocessing import LabelEncoder from keras.wrappers.scikit_learn import KerasClassifier from sklearn.model_selection import KFold from sklearn.model_selection import

Keras sentiment analysis with LSTM how to test it

隐身守侯 提交于 2019-12-23 03:46:09
问题 I'm trying to do sentiment analysis with Keras on my texts using example imdb_lstm.py but I dont know how to test it. I stored my model and weights into file and it look like this: model = model_from_json(open('my_model_architecture.json').read()) model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy']) model.load_weights('my_model_weights.h5') results = model.evaluate(X_test, y_test, batch_size=32) but ofcourse I dont know how should X_test and y_test look like.

Predicting Next Word of LSTM Model from Tensorflow Example

不羁岁月 提交于 2019-12-22 12:54:09
问题 My buddy and I are trying to utilize the trained model from the LSTM tensorflow example here. We've been able to train our model, save the model, and then import the model. We've just used tensorflow's Supervisor. It was in the tutorial, but you can read more about it here. It's weird because there's not a whole lot of clear documentation for this. I understand that tensorflow is an API that's going through a lot of changes and adaptations right now, but it's hard to find clear answers. For

Format time-series data for short term forecasting using Recurrent Neural networks

跟風遠走 提交于 2019-12-22 12:21:59
问题 I want to forecast day-ahead power consumption using recurrent neural networks (RNN). But, I find the required data format (samples, timesteps, features) for RNN as confusing. Let me explain with an example as: I have power_dataset.csv on dropbox, which contains power consumption from 5 June to 18 June at 10 minutely rate (144 observations per day). Now, to check the performance of RNN using rnn R package, I am following these steps train model M for the usage of 17 June by using data from 5

Foward pass in LSTM netwok learned by keras

∥☆過路亽.° 提交于 2019-12-22 10:02:48
问题 I have the following code that I am hoping to get a forward pass from a 2 layer LSTM: """ this is a simple numerical example of LSTM forward pass to allow deep understanding the LSTM is trying to learn the sin function by learning to predict the next value after a sequence of 3 inputs example 1: {0.583, 0.633, 0.681} --> {0.725}, these values correspond to {sin(35.66), sin(39.27}, sin(42.92)} --> {sin(46.47)} example 2: {0.725, 0.767, 0.801} --> {0.849}, these values correspond to {sin(46.47)

Strange loss curve while training LSTM with Keras

佐手、 提交于 2019-12-22 08:57:18
问题 I'm trying to train an LSTM for some a binary classification problem. When I plot loss curve after the training, there are strange picks in it. Here are some examples: Here is the basic code model = Sequential() model.add(recurrent.LSTM(128, input_shape = (columnCount,1), return_sequences=True)) model.add(Dropout(0.5)) model.add(recurrent.LSTM(128, return_sequences=False)) model.add(Dropout(0.5)) model.add(Dense(1)) model.add(Activation('sigmoid')) model.compile(optimizer='adam', loss='binary

How to generate a sentence from feature vector or words?

筅森魡賤 提交于 2019-12-22 06:38:42
问题 I used VGG 16-Layer Caffe model for image captions and I have several captions per image. Now, I want to generate a sentence from those captions (words). I read in a paper on LSTM that I should remove the SoftMax layer from the training network and provide the 4096 feature vector from fc7 layer directly to LSTM. I am new to LSTM and RNN stuff. Where should I begin? Is there any tutorial showing how to generate sentence by sequence labeling? 回答1: AFAIK the master branch of BVLC/caffe does not