NatLibFi / Annif

Annif is a multi-algorithm automated subject indexing tool for libraries, archives and museums.
https://annif.org
Other
188 stars 41 forks source link

UnboundLocalError: local variable 'logs' referenced before assignment #504

Closed TommiRTVA closed 2 years ago

TommiRTVA commented 2 years ago

I tried to use the learn-method with nn backend. Backend consists ready-made Epikurous backends (mllm, fasttext, bonsai).

I use the docker version.

nn was trained with tsv-file with 4384 short text and each had some yso-labels.

I added for one file on .tsv -format with short text and four labels.

This was the error message:

Traceback (most recent call last): File "/usr/local/bin/annif", line 33, in sys.exit(load_entry_point('annif', 'console_scripts', 'annif')()) File "/usr/local/lib/python3.7/site-packages/click/core.py", line 829, in call return self.main(*args, kwargs) File "/usr/local/lib/python3.7/site-packages/flask/cli.py", line 596, in main return super().main(args, kwargs) File "/usr/local/lib/python3.7/site-packages/click/core.py", line 782, in main rv = self.invoke(ctx) File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1259, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1066, in invoke return ctx.invoke(self.callback, ctx.params) File "/usr/local/lib/python3.7/site-packages/click/core.py", line 610, in invoke return callback(args, kwargs) File "/usr/local/lib/python3.7/site-packages/click/decorators.py", line 21, in new_func return f(get_current_context(), *args, kwargs) File "/usr/local/lib/python3.7/site-packages/flask/cli.py", line 440, in decorator return __ctx.invoke(f, *args, *kwargs) File "/usr/local/lib/python3.7/site-packages/click/core.py", line 610, in invoke return callback(args, kwargs) File "/Annif/annif/cli.py", line 233, in run_learn proj.learn(documents, backend_params) File "/Annif/annif/project.py", line 203, in learn self.backend.learn(corpus, beparams) File "/Annif/annif/backend/backend.py", line 130, in learn return self._learn(corpus, params=beparams) File "/Annif/annif/backend/nn_ensemble.py", line 209, in _learn self._fit_model(corpus, int(params['learn-epochs'])) File "/Annif/annif/backend/nn_ensemble.py", line 200, in _fit_model self._model.fit(seq, verbose=True, epochs=epochs) File "/usr/local/lib/python3.7/site-packages/tensorflow/python/keras/engine/training.py", line 108, in _method_wrapper return method(self, *args, **kwargs) File "/usr/local/lib/python3.7/site-packages/tensorflow/python/keras/engine/training.py", line 1104, in fit epoch_logs = copy.copy(logs) UnboundLocalError: local variable 'logs' referenced before assignment

Maybe related to this?

https://github.com/tensorflow/tensorflow/issues/38064

juhoinkinen commented 2 years ago

This was just fixed by PR #506 to the master branch, thanks for reporting! Note that the online learning is still an experimental feature.

I hope you can you use the master branch via development installation. If not, and if this feature is valuable to you, we could do a 0.53.2 patch release for the fix.

TommiRTVA commented 2 years ago

Would it be too much trouble if you do the 0.53.2. release?

osma commented 2 years ago

Just getting back from vacations. I believe we could do a 0.53.2 release next week.

TommiRTVA commented 2 years ago

OK, thanks.

juhoinkinen commented 2 years ago

@TommiRTVA Annif 0.53.2 has been released: https://github.com/NatLibFi/Annif/releases/tag/v0.53.2