Giter VIP home page Giter VIP logo

cnn-hierarchical-network-for-document-classification's Introduction

Hierarchical Attentional Hybrid Neural Networks for Document Classification

This paper was accepted in ICANN 2019

J. Abreu , L. Fred, D. Macêdo, C. Zanchettin, "Hierarchical Attentional Hybrid Neural Networks for Document Classification".

Performance on Yelp Dataset multi-class

Yelp multi-class|885x789

Datasets:

Dataset Classes Documents download
Yelp Reviews 2018 5 1569264 link
IMDb Movie Review 2 50000 link

Do you want use Pre-trained FastText word embeddings? Downloaded in https://www.kaggle.com/luisfredgs/wiki-news-300d-1m-subword. Check the source code for more details. Pay attention to Colab limits of RAM and GPU.

Requirements

  • Python 3
  • tensorflow 1.10
  • Keras 2.x
  • spacy 2.0
  • gensim
  • tqdm
  • matplotlib

A GPU with CUDA support is required to run this code.

Run this code on Google Colab with Free GPU

On Google Colab, Select "Runtime," "Change runtime type" to Python 3. Ensure "Hardware accelerator" is set to GPU (the default is CPU).

Open In Colab

To run this notebook on Google Colab you don't need download dataset files. Type your kaggle username and API key during cell execution and wait. Will done. If do you want to make predictions on new text data using a trained model, check make_predictions.ipynb for more details.

Please cite

@article{abreu2019hierarchical,
  title={Hierarchical Attentional Hybrid Neural Networks for Document Classification},
  author={Abreu, Jader and Fred, Luis and Mac{\^e}do, David and Zanchettin, Cleber},
  journal={arXiv preprint arXiv:1901.06610},
  year={2019}
}

cnn-hierarchical-network-for-document-classification's People

Contributors

luisfredgs 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

Watchers

 avatar  avatar  avatar  avatar  avatar

cnn-hierarchical-network-for-document-classification's Issues

use of the dataset test_x

Hello, I have a question to ask you. In your code, I didn't find the use of the dataset test_x. Did you not perform the final test?
My English is not very good, please let me know if there is something offensive.

Can't set the attribute "trainable_weights" when training model.

When I'm trying to run the code on Google Colab,
after loading fasttext.txt, an error message popped up says
AttributeError: Can't set the attribute "trainable_weights", likely because it conflicts with an existing read-only @property of the object. Please choose a different name.

It happened when I'm running

K.clear_session()
model = HAHNetwork()
model.train(X, Y, batch_size=64, epochs=8, embeddings_path=True, saved_model_dir=SAVED_MODEL_DIR, saved_model_filename=SAVED_MODEL_FILENAME)

This is the complete error message:

2020-10-30 10:56:25,664 : INFO : loading FastText object from ./fasttext_model.txt
2020-10-30 10:56:26,793 : INFO : loading wv recursively from ./fasttext_model.txt.wv.* with mmap=None
2020-10-30 10:56:26,794 : INFO : loading vectors_ngrams from ./fasttext_model.txt.wv.vectors_ngrams.npy with mmap=None
2020-10-30 10:56:26,832 : INFO : setting ignored attribute vectors_norm to None
2020-10-30 10:56:26,833 : INFO : setting ignored attribute vectors_vocab_norm to None
2020-10-30 10:56:26,835 : INFO : setting ignored attribute vectors_ngrams_norm to None
2020-10-30 10:56:26,838 : INFO : setting ignored attribute buckets_word to None
2020-10-30 10:56:26,839 : INFO : loading vocabulary recursively from ./fasttext_model.txt.vocabulary.* with mmap=None
2020-10-30 10:56:26,841 : INFO : loading trainables recursively from ./fasttext_model.txt.trainables.* with mmap=None
2020-10-30 10:56:26,843 : INFO : loading vectors_ngrams_lockf from ./fasttext_model.txt.trainables.vectors_ngrams_lockf.npy with mmap=None
2020-10-30 10:56:26,881 : INFO : loaded ./fasttext_model.txt
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/base_layer.py in __setattr__(self, name, value)
   2761       try:
-> 2762         super(tracking.AutoTrackable, self).__setattr__(name, value)
   2763       except AttributeError:

AttributeError: can't set attribute

During handling of the above exception, another exception occurred:

AttributeError                            Traceback (most recent call last)
7 frames
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/base_layer.py in __setattr__(self, name, value)
   2765             ('Can\'t set the attribute "{}", likely because it conflicts with '
   2766              'an existing read-only @property of the object. Please choose a '
-> 2767              'different name.').format(name))
   2768       return
   2769 

AttributeError: Can't set the attribute "trainable_weights", likely because it conflicts with an existing read-only @property of the object. Please choose a different name.

It seems like this is also an ongoing issue with TensorFlow and Google Colab.
Would there be any solutions to this problem?
Thank you.

ValueError: [E030] Sentence boundaries unset. You can add the 'sentencizer' component to the pipeline with: nlp.add_pipe(nlp.create_pipe('sentencizer')) Alternatively, add the dependency parser, or set sentence boundaries by setting doc[i].is_sent_start.

Hello, I have the following error when I run your file. I hope you can help me answer it.
my spacy version is 2.1.3

There is an error in this position:datase.py
for sentence in tqdm(doc.sents):

ERROR:
ValueError: [E030] Sentence boundaries unset. You can add the 'sentencizer' component to the pipeline with: nlp.add_pipe(nlp.create_pipe('sentencizer')) Alternatively, add the dependency parser, or set sentence boundaries by setting doc[i].is_sent_start.

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.