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

run predict function in Colab, get ConfigurationError: Invalid batch_type option. #212

Closed
raisinbl opened this issue Mar 23, 2023 · 0 comments

Comments

@raisinbl
Copy link

I run predict function with right config in Google Colab but I get ConfigurationError: Invalid `batch_type` option. even when the batch_type in my config.yaml is set to sentence or token (the JoeyNMT version is 2.2.0)

what I want is to get the hypothesis score for each sentence when I pass a dataset to predict function when import from joeynmt.prediction. I pretty sure that my config file is pointed correctly, and also for the config setting. I checked many times, even when run the config with python -m joeynmt test directory/config.yaml .... is okay.

I call

_, _, _, trg_tokens, trg_scores, _ = predict(
            model=model,
            data=active,
            compute_loss=False,
            device='cpu',
            n_gpu=0,
            normalization="none",
            num_workers=4,
            cfg=config,
            fp16=False,
        )

Logged output

---------------------------------------------------------------------------
ConfigurationError                        Traceback (most recent call last)
[<ipython-input-42-4c784ab329a7>](https://localhost:8080/#) in <module>
      2 
      3 print('start here')
----> 4 _, _, _, trg_tokens, trg_scores, _ = predict(
      5             model=model,
      6             data=active,

1 frames
[/usr/local/lib/python3.9/dist-packages/joeynmt/prediction.py](https://localhost:8080/#) in predict(model, data, device, n_gpu, compute_loss, normalization, num_workers, cfg, fp16)
     91         return_prob,
     92         generate_unk,
---> 93         repetition_penalty,
     94         no_repeat_ngram_size,
     95     ) = parse_test_args(cfg)

[/usr/local/lib/python3.9/dist-packages/joeynmt/helpers.py](https://localhost:8080/#) in parse_test_args(cfg)
    329     batch_type: str = cfg.get("batch_type", "sentences")
    330     print(batch_type)
--> 331     if batch_type not in ["sentence", "token"]:
    332         raise ConfigurationError(
    333             "Invalid `batch_type` option. Valid options: {`sentence`, `token`}.")

ConfigurationError: Invalid `batch_type` option. Valid options: {`sentence`, `token`}.

my configuration is

data: ...
training: ...
model: ...
testing:
    n_best: 3
    beam_size: 5
    beam_alpha: 1.0
    batch_size: 20
    batch_type: "sentence"
    max_output_length: 100
    eval_metrics: ["bleu"]
    return_prob: "hyp"
    sacrebleu_cfg:
        tokenize: "13a"
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

1 participant