Comments (8)
from nnsum.
My training command is
python script_bin/train_model.py \ --trainer --train-inputs 'data/inputs/train/' \ --train-labels 'data/labels/train/' \ --valid-inputs 'data/inputs/valid/' \ --valid-labels 'data/labels/valid/' \ --valid-refs 'data/human/valid/' \ --weight \ --epochs 50 \ --gpu 3 \ --model 'result/model' \ --results 'result/valid_score' \ --seed 12345678 \ --emb --embedding-size 200 \ --enc cnn \ --ext s2s --bidirectional
My testing command is
python script_bin/eval_model.py \ --inputs 'data/inputs/test/' \ --refs 'data/human/test/' \ --model 'result/model.pth' \ --results 'result/exp1/test_score' \ --summary-length 100 \ --batch-size 32
The error message is
Loading model...Traceback (most recent call last): File "script_bin/eval_model.py", line 92, in <module> main() File "script_bin/eval_model.py", line 41, in main vocab = model.embeddings.vocab AttributeError: 'collections.OrderedDict' object has no attribute 'embeddings'
from nnsum.
Thanks! Can you run the following commands and send me the output:
import torch
model = torch.load("result/model.pth", map_location=lambda storage, loc: storage)
print(model)
from nnsum.
The error comes because newer versions of ignite
save model checkpoints as state_dict
by default (see here).
To fix, change the nnsum code here from:
checkpoint = ModelCheckpoint(dirname, prefix, score_function=_score_func,
require_empty=False, score_name=metric_name)
to
checkpoint = ModelCheckpoint(dirname, prefix, score_function=_score_func,
require_empty=False, score_name=metric_name,
save_as_state_dict=False)
from nnsum.
Hello,
I used AMI dataset to test the code without GPU, and I met this problem:
INFO:root: Model parameter initialization finished.
INFO:ignite.engine.engine.Engine:Engine run starting with max_epochs=50.
INFO:ignite.engine.engine.Engine:Epoch[1] Complete. Time taken: 00:00:00
ERROR:ignite.engine.engine.Engine:Engine run is terminating due to exception: Loss must have at least one example before it can be computed.
Traceback (most recent call last):
File "script_bin/train_model.py", line 79, in <module>
main()
File "script_bin/train_model.py", line 76, in main
results_path=args["trainer"]["results"])
File "/home/constant/anaconda3/lib/python3.7/site-packages/nnsum-1.0-py3.7.egg/nnsum/trainer/labels_mle_trainer.py", line 164, in labels_mle_trainer
File "/home/constant/anaconda3/lib/python3.7/site-packages/ignite/engine/engine.py", line 359, in run
self._handle_exception(e)
File "/home/constant/anaconda3/lib/python3.7/site-packages/ignite/engine/engine.py", line 324, in _handle_exception
raise e
File "/home/constant/anaconda3/lib/python3.7/site-packages/ignite/engine/engine.py", line 350, in run
self._fire_event(Events.EPOCH_COMPLETED)
File "/home/constant/anaconda3/lib/python3.7/site-packages/ignite/engine/engine.py", line 259, in _fire_event
func(self, *(event_args + args), **kwargs)
File "/home/constant/anaconda3/lib/python3.7/site-packages/ignite/metrics/metric.py", line 68, in completed
result = self.compute()
File "/home/constant/anaconda3/lib/python3.7/site-packages/nnsum-1.0-py3.7.egg/nnsum/metrics/loss.py", line 21, in compute
ignite.exceptions.NotComputableError: Loss must have at least one example before it can be computed
Is it the problem caused by not using GPU? Thanks for your help!
from nnsum.
The error comes because newer versions of
ignite
save model checkpoints asstate_dict
by default (see here).To fix, change the nnsum code here from:
checkpoint = ModelCheckpoint(dirname, prefix, score_function=_score_func, require_empty=False, score_name=metric_name)
to
checkpoint = ModelCheckpoint(dirname, prefix, score_function=_score_func, require_empty=False, score_name=metric_name, save_as_state_dict=False)
I changed the code as your suggestion, but the code does not work, either. There is still the following error:
AttributeError: 'collections.OrderedDict' object has no attribute 'embeddings'
Do you have other methods to solve the problem? Thanks for your reply!
from nnsum.
from nnsum.
Can you give me the versions of python, torch, and ignite that you are using, along with the commandline arguments you are using? I can't reproduce this error. Thanks! Chris
…
On Tue, Sep 3, 2019 at 1:06 AM tlifcen @.***> wrote: The error comes because newer versions of ignite save model checkpoints as state_dict by default (see here <pytorch/ignite@79e5233#diff-18cd1a3c06de70b0e34b8fcf32940b30> ). To fix, change the nnsum code here https://github.com/kedz/nnsum/blob/master/nnsum/trainer/labels_mle_trainer.py#L244 from: checkpoint = ModelCheckpoint(dirname, prefix, score_function=_score_func, require_empty=False, score_name=metric_name) to checkpoint = ModelCheckpoint(dirname, prefix, score_function=_score_func, require_empty=False, score_name=metric_name, save_as_state_dict=False) I changed the code as your suggestion, but the code does not work, either. There is still the following error: AttributeError: 'collections.OrderedDict' object has no attribute 'embeddings' Do you have other methods to solve the problem? Thanks for your reply! — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#7?email_source=notifications&email_token=ABAZOM4PUXUSAJT4QUFUQH3QHXWDNA5CNFSM4HJIHGK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5XAVXQ#issuecomment-527305438>, or mute the thread https://github.com/notifications/unsubscribe-auth/ABAZOMZKVFULGHZTOLS3NPLQHXWDNANCNFSM4HJIHGKQ .
-- Chris Kedzie PhD Student, Dept. of Computer Science Columbia University email: [email protected] web: www.cs.columbia.edu/~kedzie
I used python3.6.9, torch0.4.1 and ignite0.2.0. And the environment is Ubuntu 16.04 LTS. I used the following command to test the code:
python script_bin/eval_model.py \
--inputs /home/constant/data/Constant-TL/dataset/summarization/nnsum/reddit/reddit/inputs/test \
--refs /home/constant/data/Constant-TL/dataset/summarization/nnsum/reddit/reddit/human-extracts/test \
--model ../dataset/summarization/nnsum/reddit_model_95_rouge-2=0.65826.pth \
--results ../dataset/summarization/nnsum/reddit/test_score \
--summary-length 100
Thanks for your reply!
from nnsum.
Related Issues (13)
- Problem downloading PubMed dataset
- What Format should be the training data? json or bin files?
- how to use the rouge_papier to test lead algorithm
- ERROR:ignite.engine.engine.Engine:Current run is terminating due to exception: 'NoneType' object has no attribute 'data'. ERROR:ignite.engine.engine.Engine:Engine run is terminating due to exception: 'NoneType' object has no attribute 'data'. HOT 1
- ERROR:ignite.engine.engine.Engine:Engine run is terminating due to exception: 'rouge'. HOT 2
- ImportError: cannot import name '_to_hours_mins_secs' HOT 1
- Add link to Arxiv paper HOT 1
- somethings goes wrong after loading data HOT 3
- ERROR:ignite.engine.engine.Engine:Engine run is terminating due to exception: Loss must have at least one example before it can be computed HOT 1
- About result on CNN/DM(non-anonymized)result using SummaRuRNN? HOT 12
- Pytorch Lightning as a back-end
- custom data
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nnsum.