Retraining nn after weighting the sources?

Skip to first unread message

Sandro Uhlmann

Aug 19, 2022, 4:31:19 AMAug 19
to Annif Users
Hi Osma, hi Juho, hi Mona,

I would like to train an nn with different backends and then calculate an optimal weighting between the sources via hyperopt. Question: Is it necessary to retrain the nn afterwards with the weighting of the sources or is this not necessary? If a retraining should be necessary: Can I use the --cache option for this?

Thank you and best regards, Sandro / German National Library

Osma Suominen

Aug 19, 2022, 6:39:22 AMAug 19
Hi Sandro!

Those are excellent questions.

First, to automatically find an optimal weighting, you should define a
simple ensemble (not NN) with the same sources. Then run annif hyperopt
on that project against a validation set (not the final test set, that
would be cheating!) with a sufficient number of trials (at least 100 or
so). That will report the best weights and you can then use them also in
the NN ensemble.

If you want to experiment with changing the weights in the NN ensemble
directly, you unfortunately cannot use the --cached option but will need
to retrain from scratch every time you change the weights. This is a
little bit unfortunate since it wouldn't be strictly necessary, but the
corpus is stored in such a way that the defined weights are already
incorporated into the preprocessed data that is stored on disk and can
be reused with the --cached option. I edited the wiki page of the NN
ensemble backend to make this a little bit clearer.

Anyway, I recommend that you use the first option, running hyperopt on
the simple ensemble. Those weights should be good enough for the NN
ensemble too.

> --
> You received this message because you are subscribed to the Google
> Groups "Annif Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
> <>.
> To view this discussion on the web visit
> <>.

Osma Suominen
D.Sc. (Tech), Information Systems Specialist
National Library of Finland
P.O. Box 15 (Unioninkatu 36)
Tel. +358 50 3199529

Sandro Uhlmann

Aug 19, 2022, 7:29:38 AMAug 19
to Annif Users
Hello Osma,

Thank you very much for the quick and detailed information!

I will follow your recommendation and use hyperopt with the simple ensemble to calculate the weights and then use these weights for the nn as well.

Greetings to Helsinki, Sandro
Reply all
Reply to author
0 new messages