问题
I get the following deprecation warning when saving/loading a gensim word embedding:
model.save("mymodel.model")
/home/.../lib/python3.7/site-packages/smart_open/smart_open_lib.py:398:
UserWarning: This function is deprecated, use smart_open.open instead.
See the migration notes for details:
https://github.com/RaRe-Technologies/smart_open/blob/master/README.rst#migrating-to-the-new-open-function
'See the migration notes for details: %s' % _MIGRATION_NOTES_URL
I don't understand what to do following the notes on the page. So, how should I save and open my models instead?
I use python 3.7 , gensim 3.7.3. and smart_open 1.8.4. I think I did not get the warning when using gensim 3.7.1. and python 3.5. smart_open should have been 1.8.4.
回答1:
You can ignore most "deprecation warnings", as they're just an advisory about underlying changes that for now still work, but there's a new preferred way to do things that may be required in the future.
In this case, the warning is about a function inside the smart_open
package that the gensim
package is using. That is, it's not the .save()
you are calling that's deprecated, but something inside .save()
. The gensim
authors will eventually update .save()
to use the newly-preferred variant of what smart_open
offers.
You can just keep using .save()
, ignoring the message as long as things still work for you – unless you'd like to contribute the fix to .save()
to remove the warning to gensim
. (It may, however, have already been fixed in the development code, to become available in the next gensim
release.)
来源:https://stackoverflow.com/questions/56456051/gensim-save-load-model-deprecation-warning