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.
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
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