Skip to content Skip to sidebar Skip to footer

H5py.file(path) Doesn't Recognize Folder Path

I am in my project folder call 'project'. I have two neural network h5 file, one in 'project/my_folder/my_model_1.h5', I also copy it to folder 'project/my_model_2.h5'. So I open m

Solution 1:

So it looks like some hidden invalid character incidentally got copied when I simply copy and paste the file path from Mac folder system. Take a look at the code in the screen. enter image description here

The Line 92 is the path name I directly copy and paste from Mac folder.

The Line 93 is the path I literally type with every single letter, then there is no error and .h5 file is loaded properly. It's a kinda of similar issue that has been spotted by someone at this link: Invalid character in identifier

I simply copy the error code to Pycharm, and the unwelcome character got busted.

enter image description here

So solution, for Mac user, be careful of of just simply copying the text from folder system, if something obviously weird, try type every letter into the text editor.

Solution 2:

Specifying the absolute path using the os worked in windows

file_name = os.path.dirname(__file__) +'\\my_folder\\my_model_1.h5'f = h5py.File(file_name)

dont forget to import os though

Post a Comment for "H5py.file(path) Doesn't Recognize Folder Path"