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 Issues

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.

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.

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.

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?.

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?

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.

No paper?

Did you publish some papers about the project?

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

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

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.

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

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 ?

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.