flairNLP / flair

A very simple framework for state-of-the-art Natural Language Processing (NLP)
https://flairnlp.github.io/flair/
Other
13.98k stars 2.1k forks source link

Can't increase the num_workers? #762

Closed AdityaSoni19031997 closed 5 years ago

AdityaSoni19031997 commented 5 years ago

PS Very New Flair User :)

Can't increase the num_workers...

To Reproduce

document_embeddings = DocumentRNNEmbeddings(word_embeddings,
                                            hidden_size=512,
                                            rnn_layers = 1,
                                            bidirectional=True,
                                            dropout = 0.23,
                                            reproject_words=True,
                                            reproject_words_dimension=256,
                                           )
classifier = TextClassifier(document_embeddings, label_dictionary=corpus.make_label_dictionary(), multi_label=False)
trainer = ModelTrainer(classifier, corpus)
trainer.train('./stacked_embeddings/',num_workers=16, max_epochs=10, mini_batch_size= 32, 
              learning_rate=0.1, anneal_factor=0.5, train_with_dev=True)

Expected behavior I expected to allow the Trainer.train() to increase the num_workers as such.. reference

Traceback

2019-05-28 18:15:22,483 Evaluation method: MICRO_F1_SCORE
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-22-6d2706307a23> in <module>
      1 trainer = ModelTrainer(classifier, corpus)
      2 trainer.train('./stacked_embeddings/',num_workers=16, max_epochs=10, mini_batch_size= 32, 
----> 3               learning_rate=0.1, anneal_factor=0.5, train_with_dev=True)

~/.local/lib/python3.7/site-packages/flair/trainers/trainer.py in train(self, base_path, evaluation_metric, learning_rate, mini_batch_size, eval_mini_batch_size, max_epochs, anneal_factor, patience, anneal_against_train_loss, train_with_dev, monitor_train, embeddings_in_memory, checkpoint, save_final_model, anneal_with_restarts, test_mode, param_selection_mode, **kwargs)
     80             weight_extractor = WeightExtractor(base_path)
     81 
---> 82         optimizer = self.optimizer(self.model.parameters(), lr=learning_rate, **kwargs)
     83         if self.optimizer_state is not None:
     84             optimizer.load_state_dict(self.optimizer_state)

TypeError: __init__() got an unexpected keyword argument 'num_workers'

But it's defined here,

Enviornments

alanakbik commented 5 years ago

Hello @AdityaSoni19031997 did you install from pip? If so, this feature is not yet available. The feature is only available currently if you work on the master branch, which you could install like this:

!pip install --upgrade git+https://github.com/zalandoresearch/flair.git
AdityaSoni19031997 commented 5 years ago

Yep I installed from pip! Thanks for the info guys, will pull the master branch :)

On Wed, 29 May 2019, 01:01 Alan Akbik, notifications@github.com wrote:

Hello @AdityaSoni19031997 https://github.com/AdityaSoni19031997 did you install from pip? If so, this feature is not yet available. The feature is only available currently if you work on the master branch, which you could install like this:

!pip install --upgrade git+https://github.com/zalandoresearch/flair.git

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/zalandoresearch/flair/issues/762?email_source=notifications&email_token=AFNPJJUZKU2JOYFMOXA4I2DPXWB7ZA5CNFSM4HQF7OTKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWNF7DI#issuecomment-496656269, or mute the thread https://github.com/notifications/unsubscribe-auth/AFNPJJQ4ELYBVI52JG7DJX3PXWB7ZANCNFSM4HQF7OTA .