Using Keras on Google cloud ml:
Saving model from training:
model.save('model.h5')
if cfg.cloud:
# Copy model.h5 over to Google Cloud Storage
with file_io.FileIO('model.h5', mode='rb') as input_f:
with file_io.FileIO(data_folder + 'model.h5', mode='wb+') as output_f:
output_f.write(input_f.read())
Note: not saving to job_folder, I need to read this later, not wanting to keep track of the latest job (even if that's a good way to keep models apart).
Now I want to read from my next run:
f = file_io.FileIO(model_file, mode='rb')
model = load_model(f)
model.load_weights(f)
Where 'model_file' is given as input in my submission, pointing at
--model-file gs://$BUCKET_NAME/resources/model.h5
Complains from google cloud ml jobs:
TypeError: expected str, bytes or os.PathLike object, not FileIO
I tried a number of things, but my basic question is: what's the best practice writing and especially reading in models from gcp buckets?