sentiment-analysis-spanish / sentiment-spanish

MIT License
61 stars 13 forks source link

'PosixPath' object has no attribute 'endswith' #2

Closed astrid-net closed 4 years ago

astrid-net commented 4 years ago

Hi. First of all my congrats. Your work is awesome. I'm trying to use the package. I have latest version of keras (2.3.0) and 2.2.x version of Tensorflow. But when I try to run he code I got the following error:

File "/home/rootdebian/.local/lib/python3.7/site-packages/tensorflow/python/keras/engine/network.py", line 1616, in _is_hdf5_filepath return (filepath.endswith('.h5') or filepath.endswith('.keras') or AttributeError: 'PosixPath' object has no attribute 'endswith'

Wait for your answers. Thanks for reading.

naveranoc commented 4 years ago

I had the same problem, this is due to the loading of the weights that are in h5 format, it is because when using path the class is not text and therefore it does not have the "ends_with" attribute (which str have) because of this, the solution is to put

self.loaded_model.load_weights (str (self.parent_path / "saved_model / model.h5"))

@HugoJBello I don't have much idea of git fixes, but it worked for me.

HugoJBello commented 4 years ago

Thank you very much @giaccomgl for the question and @naveranoc for the solution.

@naveranoc I implemented your solutions, it seems to me that you are right and there was a problem sometimes when loading the weight file. I created a new version in pypi.

Tell me if you still have any problems