Skip to content

Instantly share code, notes, and snippets.

@sherwoac
Created August 5, 2024 17:17
Show Gist options
  • Save sherwoac/180438367d4ca009e3672632247dac30 to your computer and use it in GitHub Desktop.
Save sherwoac/180438367d4ca009e3672632247dac30 to your computer and use it in GitHub Desktop.
scripts to change model config from keras 2->3 compliant
# hack to change model config from keras 2->3 compliant
import h5py
f = h5py.File(savedModelPath, mode="r+")
model_config_string = f.attrs.get("model_config")
if model_config_string.find('"groups": 1,') != -1:
model_config_string = model_config_string.replace('"groups": 1,', '')
f.attrs.modify('model_config', model_config_string)
f.flush()
model_config_string = f.attrs.get("model_config")
assert model_config_string.find('"groups": 1,') == -1
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment