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

How to prediect with my own train set? #122

Open
NGC2237-wei opened this issue Nov 16, 2021 · 3 comments
Open

How to prediect with my own train set? #122

NGC2237-wei opened this issue Nov 16, 2021 · 3 comments

Comments

@NGC2237-wei
Copy link

No description provided.

@NGC2237-wei
Copy link
Author

NGC2237-wei commented Nov 16, 2021

I'm trying to predient with my own train set using ner model, i create a new train set like provided,but i meet the problem like this.

@NGC2237-wei
Copy link
Author

NGC2237-wei commented Nov 16, 2021

tensor([[0., -0., -0., ..., -0., -0., 0.],
[0., -0., -0., ..., -0., -0., 0.],
[0., -0., -0., ..., -0., -0., 0.],
...,
[-0., -0., 0., ..., -0., -0., 0.],
[0., -0., 0., ..., -0., -0., 0.],
[0., -0., 0., ..., -0., -0., 0.]])
predictions.shape torch.Size([416, 63])
gold_labels.shape torch.Size([42412])

42412 is my train set size

@NGC2237-wei
Copy link
Author

The prediction shape is not equal the gold_labels.shape

Traceback (most recent call last):
File "/home/anaconda3/envs/scispacy/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/home/anaconda3/envs/scispacy/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/home/scib/src/allennlp/allennlp/run.py", line 21, in
run()
File "/home/home/scib/src/allennlp/allennlp/run.py", line 18, in run
main(prog="allennlp")
File "/home/home/scib/src/allennlp/allennlp/commands/init.py", line 102, in main
args.func(args)
File "/home/scib/src/allennlp/allennlp/commands/train.py", line 124, in train_model_from_args
args.cache_prefix)
File "/home/home//scib/src/allennlp/allennlp/commands/train.py", line 168, in train_model_from_file
cache_directory, cache_prefix)
File "/home//homescib/src/allennlp/allennlp/commands/train.py", line 252, in train_model
metrics = trainer.train()
File "/home//hom/scib/src/allennlp/allennlp/training/trainer.py", line 552, in train
val_loss, num_batches = self._validation_loss()
File "/home//home//scib/src/allennlp/allennlp/training/trainer.py", line 489, in _validation_loss
loss = self.batch_loss(batch_group, for_training=False)
File "/home//home//scib/src/allennlp/allennlp/training/trainer.py", line 279, in batch_loss
output_dict = self.model(**batch)
File "/home//anaconda3/envs/scispacy/lib/python3.6/site-packages/torch/nn/modules/module.py", line 722, in _call_impl
result = self.forward(*input, **kwargs)
File "/home/home//scib/src/allennlp/allennlp/models/crf_tagger.py", line 220, in forward
metric(class_probabilities, tags, mask.float())
File "/home//home//scib/src/allennlp/allennlp/training/metrics/categorical_accuracy.py", line 74, in call
correct = top_k.eq(gold_labels.unsqueeze(-1)).float()
RuntimeError: The size of tensor a (416) must match the size of tensor b (42412) at non-singleton dimension 0

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