XuezheMax / NeuroNLP2

Deep neural models for core NLP tasks (Pytorch version)
GNU General Public License v3.0
441 stars 89 forks source link

Error trying to train a model #43

Closed MinionAttack closed 3 years ago

MinionAttack commented 3 years ago

Hi,

I'm trying to test this tool but when I want to test it training a Stack-Pointer parser, even if I follow the instructions and set the paths for data and embeddings.

#!/usr/bin/env bash
CUDA_VISIBLE_DEVICES=0 OMP_NUM_THREADS=4 python -u parsing.py --mode train --config configs/parsing/stackptr.json \
 --num_epochs 600 --batch_size 32 \
 --opt adam --learning_rate 0.001 --lr_decay 0.999997 --beta1 0.9 --beta2 0.9 --eps 1e-4 --grad_clip 5.0 \
 --loss_type token --warmup_steps 40 --reset 20 --weight_decay 0.0 --unk_replace 0.5 --beam 10 \
 --word_embedding sskip --word_path "data/SSKIP/sskip.eng.100.gz" --char_embedding random \
 --punctuation '.' '``' "''" ':' ',' \
 --train "data/UD/en_ewt-ud-train.conll" \
 --dev "data/UD/en_ewt-ud-dev.conll" \
 --test "data/UD/en_ewt-ud-test.conll" \
 --model_path "models/parsing/stack-pointer/"

But when I try to execute the script I get:

$ ./scripts/run_stackptr.sh
Traceback (most recent call last):
  File "parsing.py", line 22, in <module>
    from neuronlp2.nn.utils import total_grad_norm
  File "/home/iago/Escritorio/NeuroNLP2/neuronlp2/nn/__init__.py", line 4, in <module>
    from neuronlp2.nn.crf import ChainCRF, TreeCRF
  File "/home/iago/Escritorio/NeuroNLP2/neuronlp2/nn/crf.py", line 7, in <module>
    from neuronlp2.nn.modules import BiAffine
  File "/home/iago/Escritorio/NeuroNLP2/neuronlp2/nn/modules.py", line 82, in <module>
    class BiAffine(nn.Module):
  File "/home/iago/Escritorio/NeuroNLP2/neuronlp2/nn/modules.py", line 156, in BiAffine
    @overrides
  File "/home/iago/Escritorio/NeuroNLP2/env/lib/python3.6/site-packages/overrides/overrides.py", line 88, in overrides
    return _overrides(method, check_signature, check_at_runtime)
  File "/home/iago/Escritorio/NeuroNLP2/env/lib/python3.6/site-packages/overrides/overrides.py", line 114, in _overrides
    _validate_method(method, super_class, check_signature)
  File "/home/iago/Escritorio/NeuroNLP2/env/lib/python3.6/site-packages/overrides/overrides.py", line 135, in _validate_method
    ensure_signature_is_compatible(super_method, method, is_static)
  File "/home/iago/Escritorio/NeuroNLP2/env/lib/python3.6/site-packages/overrides/signature.py", line 82, in ensure_signature_is_compatible
    ensure_return_type_compatibility(super_type_hints, sub_type_hints, method_name)
  File "/home/iago/Escritorio/NeuroNLP2/env/lib/python3.6/site-packages/overrides/signature.py", line 266, in ensure_return_type_compatibility
    f"{method_name}: return type `{sub_return}` is not a `{super_return}`."
TypeError: BiAffine.extra_repr: return type `None` is not a `<class 'str'>`.

I get the same error with:

./scripts/run_stackptr.sh and ./scripts/run_deepbiaf.sh

What I'm doing wrong?

Greetings.

MinionAttack commented 3 years ago

Ok, the code works until torch==1.5.1, from torch 1.6 and further it gives that error

XuezheMax commented 3 years ago

Thanks for your comments. I guess it is due to some compatibility of higher version of PyTorch. We will look at the issue soon.