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

TypeError: from_params() takes 2 positional arguments but 4 were given #17

Open
lx385095967 opened this issue Apr 18, 2019 · 12 comments
Open

Comments

@lx385095967
Copy link

After reading "QA-SRL", I ran the code after installing Allennlp 0.8.3. It reported an error:"TypeError: from_params() takes 2 positional arguments but 4 were given"

File "/home/lixin/Documents/qasrl-bank-master/nrl-qasrl-master/nrl/models/qasrl_parser.py", line 34, in from_params
span_detector = Model.from_params(vocab, params.pop("span_detector"))
TypeError: from_params() takes 2 positional arguments but 3 were given.

I can't find the function from_params() in the class 'model'.
So,is it the reason for the framework version? How can i solve it .

I am a beginner, thank you for your help.

@Erutan-pku
Copy link

Erutan-pku commented Apr 28, 2019

I meet a similar problem, but I have "3 were given"...😂 I do not know how to solve it ........

@lx385095967
Copy link
Author

I meet a similar problem, but I have "3 were given"...😂 I do not know how to solve it ........

If you run it on version 0.5.1 ,the demo can be operated. But training has some problems. If you get the result ,please tell me. Thanks.

@Erutan-pku
Copy link

I meet a similar problem, but I have "3 were given"...😂 I do not know how to solve it ........

If you run it on version 0.5.1 ,the demo can be operated. But training has some problems. If you get the result ,please tell me. Thanks.

Do you mean pytorch 0.4.1?
I have python3.6.5 with pytorch 0.4.1, but still have the problem when running "python3 -m allennlp.run predict ./data/qasrl_parser_elmo demo.txt --include-package nrl --predictor qasrl_parser --output-file demo.txt.out"
The demo.txt is "
{"sentence": "John went to the store."}
{"sentence": "The man ate the burrito and threw the trash in the garbage"}
"

I also met 2 import errors in "nrl/service/server_simple_gpu.py",
I changed "from gevent.wsgi import WSGIServer" to "from gevent.pywsgi import WSGIServer" and comment out "from allennlp.service.server_flask import ServerError", I do not know whether it is OK...

Do you have any idea with these? Thanks.

@lx385095967
Copy link
Author

I meet a similar problem, but I have "3 were given"...😂 I do not know how to solve it ........

If you run it on version 0.5.1 ,the demo can be operated. But training has some problems. If you get the result ,please tell me. Thanks.

Do you mean pytorch 0.4.1?
I have python3.6.5 with pytorch 0.4.1, but still have the problem when running "python3 -m allennlp.run predict ./data/qasrl_parser_elmo demo.txt --include-package nrl --predictor qasrl_parser --output-file demo.txt.out"
The demo.txt is "
{"sentence": "John went to the store."}
{"sentence": "The man ate the burrito and threw the trash in the garbage"}
"

I also met 2 import errors in "nrl/service/server_simple_gpu.py",
I changed "from gevent.wsgi import WSGIServer" to "from gevent.pywsgi import WSGIServer" and comment out "from allennlp.service.server_flask import ServerError", I do not know whether it is OK...

Do you have any idea with these? Thanks.

allennlp version=0.5.1 你可以试一下

@nafitzgerald
Copy link
Owner

This code was built for allennlp 0.5.0 and pytorch 0.4.0.

@lx385095967
Copy link
Author

This code was built for allennlp 0.5.0 and pytorch

This code was built for allennlp 0.5.0 and pytorch 0.4.0.

OK, I will try later.Thanks for your reply.

@lx385095967
Copy link
Author

This code was built for allennlp 0.5.0 and pytorch 0.4.0.

when I train the model, I face an error like this:

File "/home/leex/Documents/qasrl-bank-master/nrl-qasrl-master/nrl/metrics/threshold_metric.py", line 119, in get_matches
matching = [(g, p) for g, p in matching.items() if g in gold_spans]
AttributeError: 'set' object has no attribute 'items'

Platform: ubuntu 14/allennlp==0.5.1/torch==0.4.0

@Erutan-pku
Copy link

This code was built for allennlp 0.5.0 and pytorch 0.4.0.

That's works for predication, thank you~

I changed
self._pretrained_vectors = read_pretrained_file("https://s3-us-west-2.amazonaws.com/allennlp/datasets/glove/glove.6B.100d.txt.gz")
to
self._pretrained_vectors = read_pretrained_file("data/glove/glove.6B.100d.txt.gz")
in nrl/service/predictors/qasrl_parser.py
for utilizing local word embedding file.

@lx385095967
Copy link
Author

This code was built for allennlp 0.5.0 and pytorch 0.4.0.

That's works for predication, thank you~

I changed
self._pretrained_vectors = read_pretrained_file("https://s3-us-west-2.amazonaws.com/allennlp/datasets/glove/glove.6B.100d.txt.gz")
to
self._pretrained_vectors = read_pretrained_file("data/glove/glove.6B.100d.txt.gz")
in nrl/service/predictors/qasrl_parser.py
for utilizing local word embedding file.

Have you run the training model smoothly?

@Erutan-pku
Copy link

This code was built for allennlp 0.5.0 and pytorch 0.4.0.

That's works for predication, thank you~
I changed
self._pretrained_vectors = read_pretrained_file("https://s3-us-west-2.amazonaws.com/allennlp/datasets/glove/glove.6B.100d.txt.gz")
to
self._pretrained_vectors = read_pretrained_file("data/glove/glove.6B.100d.txt.gz")
in nrl/service/predictors/qasrl_parser.py
for utilizing local word embedding file.

Have you run the training model smoothly?

I did not run the training model, because I only need to parse several documents with the pretrained model ....

@zhibiao-boston
Copy link

I meet a similar problem, but I have "3 were given"...😂 I do not know how to solve it ........

If you run it on version 0.5.1 ,the demo can be operated. But training has some problems. If you get the result ,please tell me. Thanks.

Do you mean pytorch 0.4.1?
I have python3.6.5 with pytorch 0.4.1, but still have the problem when running "python3 -m allennlp.run predict ./data/qasrl_parser_elmo demo.txt --include-package nrl --predictor qasrl_parser --output-file demo.txt.out"
The demo.txt is "
{"sentence": "John went to the store."}
{"sentence": "The man ate the burrito and threw the trash in the garbage"}
"

I also met 2 import errors in "nrl/service/server_simple_gpu.py",
I changed "from gevent.wsgi import WSGIServer" to "from gevent.pywsgi import WSGIServer" and comment out "from allennlp.service.server_flask import ServerError", I do not know whether it is OK...

Do you have any idea with these? Thanks.

for the import error "allennlp.service.server_flask import ServerError", change it to "allennlp.service.server_simple import ServerError"

@zhibiao-boston
Copy link

This code was built for allennlp 0.5.0 and pytorch 0.4.0.

pytorch 0.4.0 is not available now.

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