Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Outdated models #5

Open
jhlq opened this issue Jun 29, 2024 · 2 comments
Open

Outdated models #5

jhlq opened this issue Jun 29, 2024 · 2 comments

Comments

@jhlq
Copy link

jhlq commented Jun 29, 2024

I installed the most recent versions of the dependencies and got the following error when running python3 kstar_simulator_v0.py:

  File "/home/admins/fysik/KSTAR_tokamak_simulator/kstar_simulator_v0.py", line 697, in <module>
    window = KSTARWidget()
  File "/home/admins/fysik/KSTAR_tokamak_simulator/kstar_simulator_v0.py", line 122, in __init__
    self.k2rz = k2rz(n_models=MAX_SHAPE_MODELS)
  File "/home/admins/fysik/KSTAR_tokamak_simulator/kstar_simulator_v0.py", line 574, in __init__
    self.models.append(models.load_model(model_path+f'/best_model{i}',custom_objects={'r2_k':r2_k}))
  File "/home/admins/.local/lib/python3.10/site-packages/keras/src/saving/saving_api.py", line 199, in load_model
    raise ValueError(
ValueError: File format not supported: filepath=/home/admins/fysik/KSTAR_tokamak_simulator/weights/k2rz/best_model0. Keras 3 only supports V3 `.keras` files and legacy H5 format files (`.h5` extension). Note that the legacy SavedModel format is not supported by `load_model()` in Keras 3. In order to reload a TensorFlow SavedModel as an inference-only layer in Keras 3, use `keras.layers.TFSMLayer(/home/admins/fysik/KSTAR_tokamak_simulator/weights/k2rz/best_model0, call_endpoint='serving_default')` (note that your `call_endpoint` might have a different name).

Is there a fix or should I downgrade Keras?

@jhlq
Copy link
Author

jhlq commented Jun 29, 2024

Trying

import keras
keras.layers.TFSMLayer("/home/admins/fysik/KSTAR_tokamak_simulator/weights/k2rz/best_model0", call_endpoint="serving_default")

Gives the error

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/admins/.local/lib/python3.10/site-packages/keras/src/export/export_lib.py", line 735, in __init__
    self._reloaded_obj = tf.saved_model.load(filepath)
  File "/home/admins/.local/lib/python3.10/site-packages/tensorflow/python/saved_model/load.py", line 912, in load
    result = load_partial(export_dir, None, tags, options)["root"]
  File "/home/admins/.local/lib/python3.10/site-packages/tensorflow/python/saved_model/load.py", line 1016, in load_partial
    loader_impl.parse_saved_model_with_debug_info(export_dir))
  File "/home/admins/.local/lib/python3.10/site-packages/tensorflow/python/saved_model/loader_impl.py", line 59, in parse_saved_model_with_debug_info
    saved_model = parse_saved_model(export_dir)
  File "/home/admins/.local/lib/python3.10/site-packages/tensorflow/python/saved_model/loader_impl.py", line 119, in parse_saved_model
    raise IOError(
OSError: SavedModel file does not exist at: /home/admins/fysik/KSTAR_tokamak_simulator/weights/k2rz/best_model0/{saved_model.pbtxt|saved_model.pb}

Also your line of code has self.models.append(models.load_model(model_path+f'/best_model{i}',custom_objects={'r2_k':r2_k})) a r2_k, how is that included?

@jhlq
Copy link
Author

jhlq commented Jun 29, 2024

Used a virtual environment with the following requirements.txt:

Keras==2.8
matplotlib==3.5.1
numpy==1.23.5
PyQt5-Qt5==5.15.2
PyQt5-sip==12.9.0
QtPy==1.9.0
scipy==1.8
tensorflow==2.8.0
protobuf==3.20

And it runs, with some issues:

2024-06-29 21:26:33.562427: W tensorflow/core/util/tensor_slice_reader.cc:96] Could not open /home/admins/fysik/KSTAR_tokamak_simulator/weights/lstm//best_model0: DATA_LOSS: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?
2024-06-29 21:26:35.007038: W tensorflow/core/util/tensor_slice_reader.cc:96] Could not open /home/admins/fysik/KSTAR_tokamak_simulator/weights/lstm//best_model1: DATA_LOSS: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?
2024-06-29 21:26:36.432100: W tensorflow/core/util/tensor_slice_reader.cc:96] Could not open /home/admins/fysik/KSTAR_tokamak_simulator/weights/lstm//best_model2: DATA_LOSS: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?
2024-06-29 21:26:38.127055: W tensorflow/core/util/tensor_slice_reader.cc:96] Could not open /home/admins/fysik/KSTAR_tokamak_simulator/weights/lstm//best_model3: DATA_LOSS: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?
2024-06-29 21:26:39.519651: W tensorflow/core/util/tensor_slice_reader.cc:96] Could not open /home/admins/fysik/KSTAR_tokamak_simulator/weights/lstm//best_model4: DATA_LOSS: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant