Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

predict() got an unexpected keyword argument 'batch_size' #51

Closed
Jean-Baptiste-Camps opened this issue Oct 2, 2017 · 8 comments
Closed

Comments

@Jean-Baptiste-Camps
Copy link

Trying to train with a PyTorch model, I encounter this error at the time of evaluation

Building model...
-> epoch  1 ...
176400/176400 [==============================] - 1570s - loss: 1.5666 - lemma_out_loss: 1.5666      

Traceback (most recent call last):
  File "main.py", line 6, in <module>
    cli_train()
  File "/home/jbcamps/02_lemmatisation/pandora_edge/pandora/cli.py", line 144, in cli_train
    train_func(**vars(parser.parse_args()))
  File "/home/jbcamps/02_lemmatisation/pandora_edge/pandora/cli.py", line 112, in train_func
    tagger.epoch(autosave=True, eval_test=tagger.include_test)
  File "/home/jbcamps/02_lemmatisation/pandora_edge/pandora/tagger.py", line 504, in epoch
    score_dict = self.logger.epoch(self.curr_nb_epochs, run_eval)
  File "/home/jbcamps/02_lemmatisation/pandora_edge/pandora/logger.py", line 69, in epoch
    score_dict = callback()
  File "/home/jbcamps/02_lemmatisation/pandora_edge/pandora/tagger.py", line 501, in run_eval
    score_dict.update(self.test())
  File "/home/jbcamps/02_lemmatisation/pandora_edge/pandora/tagger.py", line 369, in test
    test_preds = self.model.predict(test_in, batch_size=self.batch_size)
TypeError: predict() got an unexpected keyword argument 'batch_size'

Indeed, if we go to pandora/impl/base_model.py, l. 125,

def predict(self, input_data):

does not have the batch_size argument.

@Jean-Baptiste-Camps Jean-Baptiste-Camps changed the title [PyTorch impl] predict() got an unexpected keyword argument 'batch_size' predict() got an unexpected keyword argument 'batch_size' Oct 2, 2017
@emanjavacas
Copy link

what is the script you are using to run this?

@Jean-Baptiste-Camps
Copy link
Author

I am using this:

python3 main.py config_chrestien3_keras.txt --train data/chrestien3/train --dev data/chrestien3/dev --test data/chrestien3/test

with the current master version.

@Jean-Baptiste-Camps
Copy link
Author

Great, it seems to work now.

@emanjavacas
Copy link

It looks like the only place where predict(..., batch_size) is being used is here https://github.com/hipster-philology/pandora/blob/master/pandora/tagger.py#L369 and then the value passed is just the default from the tagger class. Therefore, the current use. We might have a use for applying different bacth size during prediction (since then the batch size there doesn't have an influence in performance and it can be as large as the system can afford), so I am leaving the fix as it is.

@emanjavacas
Copy link

In a side note, what are the reasons for having main.py, unseen.py and train.py as different scripts? The first two are actually the same, as far as I can see.

@mikekestemont
Copy link

mikekestemont commented Oct 2, 2017 via email

@PonteIneptique
Copy link
Member

train.py should be replaced by the content of main.py though

@emanjavacas
Copy link

I reopened this as a separate issue #52, llet's move the discussion over there!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants