GithubHelp home page GithubHelp logo

tlkh / text-emotion-classification Goto Github PK

View Code? Open in Web Editor NEW
200.0 14.0 80.0 30.61 MB

Archived - not answering issues

Jupyter Notebook 99.45% Shell 0.01% Python 0.54%
nlp sentiment-classification deep-neural-networks keras

text-emotion-classification's Introduction

Multi-class Emotion Classification for Short Texts

Associating specific emotions to short sequences of texts

We propose using "multi-channel" combinations of convolutional kernels (aka CNN) and Long Short-Term Memory (LSTM) units to classify short text sequences (in our case, tweets) into one of five emotional classes, as opposed to the typical binary (positive/negative) or ternary (positive/negative/neutral) classes.

Classifing short sequences of text into many classes is still a relatively uncommon topic of research. In particular, with the exception of Bouazizi and Ohtsuki (2017), few authors describe the effectiveness of classifing short text sequences (such as tweets) into anything more than 3 distinct classes (positive/negative/neutral). In particular, Bouazizi and Ohtsuki only achieved an overall accuracy of 56.9% or 60.2% on seven distinct classes in two of their papers. We hope to propose a new approach that can improve classification accuracy by a appreciable amount.

Our training and validation dataset is comprised of 47,288 tweets from Twitter with labelled emotions of five classes: neutral, happy, sad, anger, hate.

We have achieved a positive result by achieving more than 62% overall classification accuracy and precision.

confusion_matrix

Jupyter Notebook: 62.29% peak validation accuracy, 0.62% overall precision.

In particular, we have achieved good validation accuracy on happy, sad, hate and anger (91% precision!) classes. Hate and anger were sometimes misclassified as sadness (occurs in Test data as well).

Compared to previous papers on this specific problem (Bouazizi and Ohtsuki, 2017), we fared worse in classifying neutral. Happiness is not a good comparison due to us merging two similar classes (fun and happy, or, love and happy) as compared to the original paper.

Why are we doing this?

We are part of a team in SUTD that are working on a project to tackle the problem of Fake News. We want to prevent Singaporeans from falling victim to disinformation, hoaxes and Fake News. We are developing a system to indicate to readers (through a Chrome extension and a dedicated discussion forum) warning signs that indicate a particular article might be illegitimate. One of those warning signs are indications that people are reacting (through comments) to the news with either negative/wide spectrum of emotion, confusion, or offensive comments.

Hence, we are exploring how we can classify and label the comments on articles in a meaningful way.

Methodology

We were inspired by previous work by other pioneers in the sentiment analysis and sentence classification field. Of note are the following:

  • Convolutional Neural Networks for Sentence Classification (Yoo Kim, 2014)
  • Twitter Sentiment Analysis using combined LSTM-CNN Models (Sosa, 2017)
  • A Pattern-Based Approach for Multi-Class Sentiment Analysis in Twitter (Bouazizi and Ohtsuki, 2017)
  • Sentiment Analysis: from Binary to Multi-Class Classification (Bouazizi and Ohtsuki, 2017)
  • Experimenting with Distant Supervision for Emotion Classification (Purver and Battersby, 2012)

Choice of Neural Network Model

TLDR: why choose when you can have all?

Long Answer: We play to the strengths of the various approaches.

RNNs, especially LSTMs, are preferred for many NLP tasks as it "learns" the significance of order of sequential data (such as texts or time-series data). On the other hand, CNNs extract features from data to identify them. Previous approaches either use one method (Yoo Kim, 2014) or take a hybrid approach by using both in the same model (Sosa, 2017).

We take elements from each of the above models and extend the idea of creating multi-channel networks where we allow the model to attempt to self-learn which channels allow it to get better predictions for certain classes of data. Our hypothesis is this will allow the model to use the overall advantages of the different channels to make overall better predictions.

We call our prototype neural network BalanceNet.

Multi-channel Approach

We omit having to make the following choices:

Freezing the weights of the word embeddings from pre-trained GloVe vectors: Thus, We make a copy of the word embeddings and only allow the back-propagation to change the weights on one of two copies. This will hypothetically allow the model to both maintain generalised embeddings and learn more specific embeddings and use whichever is more suitable. This approach was proposed by Yoo Kim (2014).

Choosing the CNN kernel size: We use multiple kernel sizes to allow features of different sizes to be extracted from input data. Again, this approach was proposed by Yoo Kim (2014). The kernel sizes we used are determine by evaluating the individual performance of each kernel size.

Choosing the order of which we pass the input sequence into the model (CNN to LSTM or LSTM to CNN): Sosa (2017) showed that a LSTM-CNN model works better than a CNN-LSTM, pure CNN or pure LSTM model. However, the differences in actual accuracy remain close, and differ according to the different classes. As our intention is to extract as many features as possible from our limited sequence, we use both approaches so we can take advantage of both extract features from sequential output from the LSTM (LSTM-CNN) and extract features to be fed into LSTM (CNN-LSTM).

We can concatenate all the channels and perform max-pooling. The last layer is a fully-connected layer which will then produce a prediction via a softmax activation function.

balancenet

We introduce dropout and L2 regularisation at specific portions of the network (especially the higher kernel sizes) to reduce the possibility of over fitting the training data.

Also it actually looks like a mass balance.

Dataset

Original Dataset

The original dataset is comprised of 40,000 tweets classified into 13 emotion classes. However, previous authors have described that several of those classes were in fact extremely similar, and repeated efforts to re-label the data only result in 72% agreement. Hence, we make the decision to combine several of those classes into five final classes. These five classes are also the same as in Bouazizi and Ohtsuki (2017), with the absence of the "sarcasm" and "love" classes (Binary to Multi-Class Classification) or "fun" and "love" classes (Pattern-Based Approach for Multi-Class Sentiment Analysis).

Additional Data

We also pulled data from the Twitter using Twitter API as additional training data. The tweets are classified with their own hashtags - for example "#happy".

We feel that hashtags should be a appreciably good (but far from perfect) representation of the sentiment of the tweet. While it is conceiveable for someone to tweet something like "Uh, I got 90 for A levels #sad", this is a very small minority and can be taken to be statistical noise, which might have the added benefit of reduce over-fitting of training data.

Is the data good/appropriate?

Being tweets, the text is short, informal, and spans a wide range of subjects. Hence, there is a good chance we will be able to use this dataset to create a baseline to classify short comments on other medium (such as on news websites) into the same classes of emotion.

Testing the model on "local" data

(Warning, some hateful online language ahead!!)

We tested our model on a variety of actual comments made on Reddit and Facebook by Singaporeans in "Singlish" and in our special, local blend of online slang.

test_results

Our results led us to two conclusions:

  1. Singlish was a smaller challenge than previously expected. It is possible that some Singlish is captured in the GloVe vectors during training. In addition, it could be that the rest of the comment already provide the model sufficient hint to the emotion such that the unseen part (Singlish) is not crucial in classification.
  2. Sacarsm was the major problem. Our model did not learn sarcasm, and thus misclassifies comments which are sarcastic. In a production setting, we propose using another seperate model to detect sarcasm, and to discard the results from this model should the other model detect a high level of sarcasm.
  3. Many comments express multiple emotions. Hence, it might be worthwhile to consider multi-label classification to, for example, label a comment as both angry and sad.

In the future, we might also be also able to create a small dataset of comments with labelled emotions to further improve the accuracy of this model.

Running the Code

  1. Download pre-trained GloVe vectors from Stanford NLP. We will be using the 200-dimensional embedding pre-trained on Twitter.
  2. Place the GloVe vectors in /dataset/glove
  3. Run one of the notebooks! (highlight: BalanceNet 1.0)

General Requirements: Python 3, TensorFlow, Keras and NLTK

The model is actually light enough to be trained on a CPU. It was initially trained on my MacBook Pro.

TODO

  1. Improve pre-processing on Tweets to match the Stanford method

Principal Investigator: Timothy Liu

Contributors: Tong Hui Kang, Chia Yew Ken

Institution: Singapore University of Technology and Design (SUTD)

text-emotion-classification's People

Contributors

akshar-code avatar imgbotapp avatar tlkh avatar tonghuikang 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

text-emotion-classification's Issues

Not end train cycle

Hi,
I´ve note that in iteration number 23,
train cycle breaks down.
I don't understand the reason.
And the same error is in your notebook.
Could you help me please?.

Wrong dataset

by default, the GitHub downloads with the wrong dataset (13 feelings), for that reason, when training the model it returns an error of shape. Expected dense (,5), got (,13).
This is the correct dataset.
data.csv

Where is your dataset with the 5 classes ?

Hi , you only provide the original dataset containing 40k annotated tweets into 13 classes. Where is your dataset containing the 5 classes ? or did you merge the labels of the original into 5 classes ?

no module named _pywrap_tensorflow

After running Setup.ipynb and the ExtraFunctions.ipynb file. I get the following error..

ImportError Traceback (most recent call last)
~\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in swig_import_helper()
17 try:
---> 18 fp, pathname, description = imp.find_module('_pywrap_tensorflow', [dirname(file)])
19 except ImportError:

~\Anaconda3\lib\imp.py in find_module(name, path)
295 else:
--> 296 raise ImportError(_ERR_MSG.format(name), name=name)
297

ImportError: No module named '_pywrap_tensorflow'

I could not install tensorflow with conda as it said that tensorflow is not available in current channels. Therefore I am going with pip install.
Pls help

No paper?

Did you publish some papers about the project?

Version Issues

I had some problems while running the code in windows, I think is easier if you run it in Linux.
TensorFlow should be V1, Keras version ==2.1.5, using TensorFlow backend.

Requirements.txt file

I have been trying to run the code and have encountered multiple version issues. Would be great to have a requirements.txt file

Checkpoint

When I run the code, it appreas to have no checkpoints of "0.91.h5", how can I solve this problem? I am looking forward for your reply. Thanks a lot.

Additional Data Processing if using other GLoVE

If we want to use a different GLoVE than the twitter27B (in particular, I would like to use commoncrawl48B) do we need to do any data processing, or can we just download the vector and run the code? If that's the case, when are data_processing.py or data_processing_crawl.py used?

model doesn't learn

loss stops decreasing after 6th epoch. I have run the original model proposed.

Epoch 1/50
37831/37831 [==============================] - 646s 17ms/step - loss: 1.2934 - acc: 0.4069 - val_loss: 1.1452 - val_acc: 0.4933
WARNING:tensorflow:From C:\Users\hmtkv\miniconda3\envs\voice\lib\site-packages\keras\callbacks\tensorboard_v1.py:343: The name tf.Summary is deprecated. Please use tf.compat.v1.Summary instead.

Epoch 2/50
37831/37831 [==============================] - 562s 15ms/step - loss: 1.0629 - acc: 0.5535 - val_loss: 1.0023 - val_acc: 0.5854
Epoch 3/50
37831/37831 [==============================] - 575s 15ms/step - loss: 0.9804 - acc: 0.5960 - val_loss: 0.9605 - val_acc: 0.6059
Epoch 4/50
37831/37831 [==============================] - 645s 17ms/step - loss: 0.9549 - acc: 0.6062 - val_loss: 0.9530 - val_acc: 0.6019
Epoch 5/50
37831/37831 [==============================] - 626s 17ms/step - loss: 0.9366 - acc: 0.6144 - val_loss: 0.9421 - val_acc: 0.6145
Epoch 6/50
37831/37831 [==============================] - 629s 17ms/step - loss: 0.9300 - acc: 0.6156 - val_loss: 0.9327 - val_acc: 0.6120
Epoch 7/50
37831/37831 [==============================] - 544s 14ms/step - loss: 0.9212 - acc: 0.6218 - val_loss: 0.9239 - val_acc: 0.6161
Epoch 8/50
37831/37831 [==============================] - 610s 16ms/step - loss: 0.9136 - acc: 0.6247 - val_loss: 0.9398 - val_acc: 0.6001
Epoch 9/50
37831/37831 [==============================] - 584s 15ms/step - loss: 0.9081 - acc: 0.6259 - val_loss: 0.9309 - val_acc: 0.6196
Epoch 10/50
37831/37831 [==============================] - 596s 16ms/step - loss: 0.9053 - acc: 0.6294 - val_loss: 0.9182 - val_acc: 0.6219
Epoch 11/50
37831/37831 [==============================] - 569s 15ms/step - loss: 0.9021 - acc: 0.6310 - val_loss: 0.9335 - val_acc: 0.6093
Epoch 12/50
37831/37831 [==============================] - 636s 17ms/step - loss: 0.8967 - acc: 0.6321 - val_loss: 0.9365 - val_acc: 0.6095
Epoch 13/50
37831/37831 [==============================] - 596s 16ms/step - loss: 0.8950 - acc: 0.6323 - val_loss: 0.9366 - val_acc: 0.6045
Epoch 14/50
37831/37831 [==============================] - 567s 15ms/step - loss: 0.8917 - acc: 0.6336 - val_loss: 0.9196 - val_acc: 0.6196
Epoch 15/50
37831/37831 [==============================] - 511s 13ms/step - loss: 0.8883 - acc: 0.6364 - val_loss: 0.9240 - val_acc: 0.6159
Epoch 16/50
37831/37831 [==============================] - 517s 14ms/step - loss: 0.8846 - acc: 0.6380 - val_loss: 0.9149 - val_acc: 0.6217
Epoch 17/50
37831/37831 [==============================] - 569s 15ms/step - loss: 0.8834 - acc: 0.6382 - val_loss: 0.9154 - val_acc: 0.6224
Epoch 18/50
37831/37831 [==============================] - 552s 15ms/step - loss: 0.8813 - acc: 0.6394 - val_loss: 0.9192 - val_acc: 0.6173
Epoch 19/50
37831/37831 [==============================] - 547s 14ms/step - loss: 0.8770 - acc: 0.6395 - val_loss: 0.9123 - val_acc: 0.6243
Epoch 20/50
37831/37831 [==============================] - 541s 14ms/step - loss: 0.8782 - acc: 0.6387 - val_loss: 0.9128 - val_acc: 0.6243
Epoch 21/50
37831/37831 [==============================] - 499s 13ms/step - loss: 0.8747 - acc: 0.6405 - val_loss: 0.9135 - val_acc: 0.6214
Epoch 22/50
37831/37831 [==============================] - 495s 13ms/step - loss: 0.8718 - acc: 0.6422 - val_loss: 0.9158 - val_acc: 0.6254
Epoch 23/50
37831/37831 [==============================] - 502s 13ms/step - loss: 0.8687 - acc: 0.6428 - val_loss: 0.9141 - val_acc: 0.6229
Epoch 24/50
37831/37831 [==============================] - 502s 13ms/step - loss: 0.8685 - acc: 0.6441 - val_loss: 0.9259 - val_acc: 0.6181
Epoch 25/50
37831/37831 [==============================] - 496s 13ms/step - loss: 0.8670 - acc: 0.6445 - val_loss: 0.9172 - val_acc: 0.6224
Epoch 26/50
37831/37831 [==============================] - 500s 13ms/step - loss: 0.8630 - acc: 0.6449 - val_loss: 0.9139 - val_acc: 0.6253
Epoch 27/50
37831/37831 [==============================] - 498s 13ms/step - loss: 0.8664 - acc: 0.6452 - val_loss: 0.9140 - val_acc: 0.6256
Epoch 28/50
37831/37831 [==============================] - 499s 13ms/step - loss: 0.8607 - acc: 0.6485 - val_loss: 0.9216 - val_acc: 0.6204
Epoch 29/50
37831/37831 [==============================] - 497s 13ms/step - loss: 0.8587 - acc: 0.6470 - val_loss: 0.9201 - val_acc: 0.6235
Epoch 30/50
37831/37831 [==============================] - 519s 14ms/step - loss: 0.8573 - acc: 0.6503 - val_loss: 0.9126 - val_acc: 0.6276
Epoch 31/50
37831/37831 [==============================] - 539s 14ms/step - loss: 0.8547 - acc: 0.6507 - val_loss: 0.9187 - val_acc: 0.6156
Epoch 32/50
37831/37831 [==============================] - 534s 14ms/step - loss: 0.8540 - acc: 0.6514 - val_loss: 0.9169 - val_acc: 0.6205
Epoch 33/50
37831/37831 [==============================] - 531s 14ms/step - loss: 0.8525 - acc: 0.6509 - val_loss: 0.9129 - val_acc: 0.6229
Epoch 34/50
37831/37831 [==============================] - 522s 14ms/step - loss: 0.8490 - acc: 0.6532 - val_loss: 0.9189 - val_acc: 0.6230
Epoch 35/50
37831/37831 [==============================] - 510s 13ms/step - loss: 0.8508 - acc: 0.6509 - val_loss: 0.9140 - val_acc: 0.6247
Epoch 36/50
37831/37831 [==============================] - 520s 14ms/step - loss: 0.8471 - acc: 0.6526 - val_loss: 0.9153 - val_acc: 0.6223
Epoch 37/50
37831/37831 [==============================] - 551s 15ms/step - loss: 0.8435 - acc: 0.6544 - val_loss: 0.9203 - val_acc: 0.6221
Epoch 38/50
37831/37831 [==============================] - 556s 15ms/step - loss: 0.8431 - acc: 0.6535 - val_loss: 0.9227 - val_acc: 0.6165
Epoch 39/50
37831/37831 [==============================] - 539s 14ms/step - loss: 0.8416 - acc: 0.6549 - val_loss: 0.9120 - val_acc: 0.6279
Epoch 40/50
37831/37831 [==============================] - 526s 14ms/step - loss: 0.8421 - acc: 0.6576 - val_loss: 0.9158 - val_acc: 0.6229
Epoch 41/50
37831/37831 [==============================] - 519s 14ms/step - loss: 0.8367 - acc: 0.6571 - val_loss: 0.9210 - val_acc: 0.6176
Epoch 42/50
37831/37831 [==============================] - 534s 14ms/step - loss: 0.8358 - acc: 0.6585 - val_loss: 0.9153 - val_acc: 0.6269
Epoch 43/50
37831/37831 [==============================] - 520s 14ms/step - loss: 0.8371 - acc: 0.6589 - val_loss: 0.9183 - val_acc: 0.6229
Epoch 44/50
37831/37831 [==============================] - 522s 14ms/step - loss: 0.8355 - acc: 0.6588 - val_loss: 0.9215 - val_acc: 0.6228
Epoch 45/50
37831/37831 [==============================] - 502s 13ms/step - loss: 0.8325 - acc: 0.6585 - val_loss: 0.9206 - val_acc: 0.6231
Epoch 46/50
37831/37831 [==============================] - 498s 13ms/step - loss: 0.8321 - acc: 0.6606 - val_loss: 0.9210 - val_acc: 0.6186
Epoch 47/50
37831/37831 [==============================] - 499s 13ms/step - loss: 0.8282 - acc: 0.6611 - val_loss: 0.9249 - val_acc: 0.6227
Epoch 48/50
37831/37831 [==============================] - 507s 13ms/step - loss: 0.8279 - acc: 0.6616 - val_loss: 0.9199 - val_acc: 0.6219
Epoch 49/50
37831/37831 [==============================] - 499s 13ms/step - loss: 0.8262 - acc: 0.6620 - val_loss: 0.9245 - val_acc: 0.6217
Epoch 50/50
37831/37831 [==============================] - 498s 13ms/step - loss: 0.8252 - acc: 0.6624 - val_loss: 0.9290 - val_acc: 0.6195

It seems like using such complex network didn't work very well for twitter.

ValueError: None values not supported.

When I run this I get the following error. I didn't modify any of the code. Any ideas on why this is happening?


ValueError Traceback (most recent call last)
in
2 model_log = model.fit(x_train, y_train, validation_data=(x_val, y_val),
3 epochs=200, batch_size=128,
----> 4 callbacks=[tensorboard, model_checkpoints])
5
6 pandas.DataFrame(model_log.history).to_csv("history-balance.csv")

~/anaconda3/envs/py36/lib/python3.6/site-packages/keras/engine/training.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, **kwargs)
1573 else:
1574 ins = x + y + sample_weights
-> 1575 self._make_train_function()
1576 f = self.train_function
1577

~/anaconda3/envs/py36/lib/python3.6/site-packages/keras/engine/training.py in _make_train_function(self)
958 training_updates = self.optimizer.get_updates(
959 params=self._collected_trainable_weights,
--> 960 loss=self.total_loss)
961 updates = self.updates + training_updates
962 # Gets loss and metrics. Updates weights at each call.

~/anaconda3/envs/py36/lib/python3.6/site-packages/keras/legacy/interfaces.py in wrapper(*args, **kwargs)
85 warnings.warn('Update your ' + object_name + 86 ' call to the Keras 2 API: ' + signature, stacklevel=2)
---> 87 return func(*args, **kwargs)
88 wrapper._original_function = func
89 return wrapper

~/anaconda3/envs/py36/lib/python3.6/site-packages/keras/optimizers.py in get_updates(self, loss, params)
360
361 # use the new accumulator and the old delta_accumulator
--> 362 update = g * K.sqrt(d_a + self.epsilon) / K.sqrt(new_a + self.epsilon)
363 new_p = p - lr * update
364

~/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/ops/variables.py in _run_op(a, *args)
752 def _run_op(a, *args):
753 # pylint: disable=protected-access
--> 754 return getattr(ops.Tensor, operator)(a._AsTensor(), *args)
755 # Propagate doc to wrapper
756 try:

~/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/ops/math_ops.py in binary_op_wrapper(x, y)
883 if not isinstance(y, sparse_tensor.SparseTensor):
884 try:
--> 885 y = ops.convert_to_tensor(y, dtype=x.dtype.base_dtype, name="y")
886 except TypeError:
887 # If the RHS is not a tensor, it might be a tensor aware object

~/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/framework/ops.py in convert_to_tensor(value, dtype, name, preferred_dtype)
834 name=name,
835 preferred_dtype=preferred_dtype,
--> 836 as_ref=False)
837
838

~/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/framework/ops.py in internal_convert_to_tensor(value, dtype, name, as_ref, preferred_dtype, ctx)
924
925 if ret is None:
--> 926 ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
927
928 if ret is NotImplemented:

~/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/framework/constant_op.py in _constant_tensor_conversion_function(v, dtype, name, as_ref)
227 as_ref=False):
228 _ = as_ref
--> 229 return constant(v, dtype=dtype, name=name)
230
231

~/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/framework/constant_op.py in constant(value, dtype, shape, name, verify_shape)
206 tensor_value.tensor.CopyFrom(
207 tensor_util.make_tensor_proto(
--> 208 value, dtype=dtype, shape=shape, verify_shape=verify_shape))
209 dtype_value = attr_value_pb2.AttrValue(type=tensor_value.tensor.dtype)
210 const_tensor = g.create_op(

~/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/framework/tensor_util.py in make_tensor_proto(values, dtype, shape, verify_shape)
369 else:
370 if values is None:
--> 371 raise ValueError("None values not supported.")
372 # if dtype is provided, forces numpy array to be the type
373 # provided if possible.

ValueError: None values not supported.

Converting sparse IndexedSlices to a dense Tensor of unknown shape.

When running the training I am getting the following error messages

/text-emotion-classification/venv/lib/python3.6/site-packages/tensorflow_core/python/framework/indexed_slices.py:433: UserWarning: Converting sparse IndexedSlices to a dense Tensor of unknown shape. This may consume a large amount of memory.
"Converting sparse IndexedSlices to a dense Tensor of unknown shape. "

ValueError Traceback (most recent call last)

in
2 model_log = model.fit(x_train, y_train, validation_data=(x_val, y_val),
3 epochs=200, batch_size=128,
----> 4 callbacks=[tensorboard, model_checkpoints])
5
6 pandas.DataFrame(model_log.history).to_csv("history-balance.csv")

~/PycharmProjects/text-emotion-classification/venv/lib/python3.6/site-packages/keras/engine/training.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_freq, max_queue_size, workers, use_multiprocessing, **kwargs)
1211 else:
1212 fit_inputs = x + y + sample_weights
-> 1213 self._make_train_function()
1214 fit_function = self.train_function
1215

~/PycharmProjects/text-emotion-classification/venv/lib/python3.6/site-packages/keras/engine/training.py in _make_train_function(self)
314 training_updates = self.optimizer.get_updates(
315 params=self._collected_trainable_weights,
--> 316 loss=self.total_loss)
317 updates = self.updates + training_updates
318

~/PycharmProjects/text-emotion-classification/venv/lib/python3.6/site-packages/keras/legacy/interfaces.py in wrapper(*args, **kwargs)
89 warnings.warn('Update your ' + object_name + ' call to the ' +
90 'Keras 2 API: ' + signature, stacklevel=2)
---> 91 return func(*args, **kwargs)
92 wrapper._original_function = func
93 return wrapper

~/PycharmProjects/text-emotion-classification/venv/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py in symbolic_fn_wrapper(*args, **kwargs)
73 if _SYMBOLIC_SCOPE.value:
74 with get_graph().as_default():
---> 75 return func(*args, **kwargs)
76 else:
77 return func(*args, **kwargs)

~/PycharmProjects/text-emotion-classification/venv/lib/python3.6/site-packages/keras/optimizers.py in get_updates(self, loss, params)
433
434 # use the new accumulator and the old delta_accumulator
--> 435 update = g * K.sqrt(d_a + self.epsilon) / K.sqrt(new_a + self.epsilon)
436 new_p = p - lr * update
437

~/PycharmProjects/text-emotion-classification/venv/lib/python3.6/site-packages/tensorflow_core/python/ops/variables.py in _run_op(a, *args, **kwargs)
1080 def _run_op(a, *args, **kwargs):
1081 # pylint: disable=protected-access
-> 1082 return tensor_oper(a.value(), *args, **kwargs)
1083
1084 functools.update_wrapper(_run_op, tensor_oper)

~/PycharmProjects/text-emotion-classification/venv/lib/python3.6/site-packages/tensorflow_core/python/ops/math_ops.py in binary_op_wrapper(x, y)
904 try:
905 y = ops.convert_to_tensor_v2(
--> 906 y, dtype_hint=x.dtype.base_dtype, name="y")
907 except TypeError:
908 # If the RHS is not a tensor, it might be a tensor aware object

~/PycharmProjects/text-emotion-classification/venv/lib/python3.6/site-packages/tensorflow_core/python/framework/ops.py in convert_to_tensor_v2(value, dtype, dtype_hint, name)
1254 name=name,
1255 preferred_dtype=dtype_hint,
-> 1256 as_ref=False)
1257
1258

~/PycharmProjects/text-emotion-classification/venv/lib/python3.6/site-packages/tensorflow_core/python/framework/ops.py in convert_to_tensor(value, dtype, name, as_ref, preferred_dtype, dtype_hint, ctx, accepted_result_types)
1312
1313 if ret is None:
-> 1314 ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
1315
1316 if ret is NotImplemented:

~/PycharmProjects/text-emotion-classification/venv/lib/python3.6/site-packages/tensorflow_core/python/framework/constant_op.py in _constant_tensor_conversion_function(v, dtype, name, as_ref)
315 as_ref=False):
316 _ = as_ref
--> 317 return constant(v, dtype=dtype, name=name)
318
319

~/PycharmProjects/text-emotion-classification/venv/lib/python3.6/site-packages/tensorflow_core/python/framework/constant_op.py in constant(value, dtype, shape, name)
256 """
257 return _constant_impl(value, dtype, shape, name, verify_shape=False,
--> 258 allow_broadcast=True)
259
260

~/PycharmProjects/text-emotion-classification/venv/lib/python3.6/site-packages/tensorflow_core/python/framework/constant_op.py in _constant_impl(value, dtype, shape, name, verify_shape, allow_broadcast)
294 tensor_util.make_tensor_proto(
295 value, dtype=dtype, shape=shape, verify_shape=verify_shape,
--> 296 allow_broadcast=allow_broadcast))
297 dtype_value = attr_value_pb2.AttrValue(type=tensor_value.tensor.dtype)
298 const_tensor = g._create_op_internal( # pylint: disable=protected-access

~/PycharmProjects/text-emotion-classification/venv/lib/python3.6/site-packages/tensorflow_core/python/framework/tensor_util.py in make_tensor_proto(values, dtype, shape, verify_shape, allow_broadcast)
437 else:
438 if values is None:
--> 439 raise ValueError("None values not supported.")
440 # if dtype is provided, forces numpy array to be the type
441 # provided if possible.

ValueError: None values not supported.

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.