Skip to content
Advertisement

Access denied to subclassed Keras model when loaded from a .py script

I have the following subclassed Keras model which I have already trained. I want to be able to call all the methods in B_frame_CNN (e.g., get_embedding()) on the loaded model. The following code works perfectly and does what I need when run in an ipython notebook.

JavaScript

However, when I run it in a python script (.py), I get the following error:

2022-09-10 01:44:08.287034: W tensorflow/core/util/tensor_slice_reader.cc:95] Could not open D:brain_cancer_octsaved_modelsCNN_bframe: Unknown: NewRandomAccessFile failed to Create/Open: D:brain_cancer_octsaved_modelsCNN_bframe : Access is denied. ; Input/output error

I would appreciate any help deciphering this error.

Advertisement

Answer

In case anyone stumbles upon the same problem, here is the workaround I found:

JavaScript

I can’t use my class methods on bframe_model alone, but once I load its weights into an object of the BFrameCNN class that I instantiate, I am able to do what I want (e.g., call the get_intermediate() method).

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement