Keras allows for saving entire models or just model weights (see thread). When saving the weights, they must be saved to a file, eg:
model = keras_model()
model.save_weights('/tmp/model.h5')
Instead of writing to file, I'd like to just save the bytes into memory. Something like
model.dump_weights()
Tensorflow doesn't seem to have this, so as a workaround I'm writing to disk and then reading into memory:
temp = '/tmp/weights.h5'
model.save_weights(temp)
with open(temp, 'rb') as f:
weightbytes = f.read()
Any way to avoid this roundabout?