-
Notifications
You must be signed in to change notification settings - Fork 75.3k
Closed
Closed
Copy link
Labels
Fixed in NightlyIssues that are resolved in nightly versionIssues that are resolved in nightly versionTF 2.13For issues related to Tensorflow 2.13For issues related to Tensorflow 2.13comp:kerasKeras related issuesKeras related issuesstaleThis label marks the issue/pr stale - to be closed automatically if no activityThis label marks the issue/pr stale - to be closed automatically if no activitystat:awaiting responseStatus - Awaiting response from authorStatus - Awaiting response from authortype:bugBugBug
Description
Issue type
Bug
Have you reproduced the bug with TensorFlow Nightly?
No
Source
binary
TensorFlow version
v2.13.0-rc2-7-g1cb1a030a62 2.13.0
Custom code
Yes
OS platform and distribution
MacOS ARM M1
Mobile device
No response
Python version
3.10.13
Bazel version
No response
GCC/compiler version
No response
CUDA/cuDNN version
No response
GPU model and memory
No response
Current behavior?
When running the code below we get the following error: AttributeError: 'Adam' object has no attribute 'build'
Standalone code to reproduce the issue
from tensorflow import keras
if __name__ == '__main__':
optimizer = keras.optimizers.Adam()
vh = keras.Input(shape=(2,3), name = 'vh')
v1 = keras.layers.Dense(512)(vh)
output = keras.layers.Dense(1, activation='softmax', name='prediction')(v1)
model = keras.Model(inputs=vh, outputs=[output], name="antibody_model")
model.compile(optimizer=optimizer )
model.save('nn_model.keras')
test = keras.models.load_model('nn_model.keras')Relevant log output
Traceback (most recent call last):
File "/opt/homebrew/Cellar/python@3.10/3.10.13/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/opt/homebrew/Cellar/python@3.10/3.10.13/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/Users/palmito/Development/federated-demo/backend/app/test.py", line 15, in <module>
test = keras.models.load_model('nn_model.keras')
File "/Users/palmito/.local/share/virtualenvs/backend-tPS_SUas/lib/python3.10/site-packages/keras/src/saving/saving_api.py", line 230, in load_model
return saving_lib.load_model(
File "/Users/palmito/.local/share/virtualenvs/backend-tPS_SUas/lib/python3.10/site-packages/keras/src/saving/saving_lib.py", line 275, in load_model
raise e
File "/Users/palmito/.local/share/virtualenvs/backend-tPS_SUas/lib/python3.10/site-packages/keras/src/saving/saving_lib.py", line 240, in load_model
model = deserialize_keras_object(
File "/Users/palmito/.local/share/virtualenvs/backend-tPS_SUas/lib/python3.10/site-packages/keras/src/saving/serialization_lib.py", line 710, in deserialize_keras_object
instance.compile_from_config(compile_config)
File "/Users/palmito/.local/share/virtualenvs/backend-tPS_SUas/lib/python3.10/site-packages/keras/src/engine/training.py", line 3582, in compile_from_config
self.optimizer.build(self.trainable_variables)
File "/Users/palmito/.local/share/virtualenvs/backend-tPS_SUas/lib/python3.10/site-packages/keras/src/optimizers/legacy/optimizer_v2.py", line 997, in __getattribute__
raise e
File "/Users/palmito/.local/share/virtualenvs/backend-tPS_SUas/lib/python3.10/site-packages/keras/src/optimizers/legacy/optimizer_v2.py", line 987, in __getattribute__
return super().__getattribute__(name)
AttributeError: 'Adam' object has no attribute 'build'Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Fixed in NightlyIssues that are resolved in nightly versionIssues that are resolved in nightly versionTF 2.13For issues related to Tensorflow 2.13For issues related to Tensorflow 2.13comp:kerasKeras related issuesKeras related issuesstaleThis label marks the issue/pr stale - to be closed automatically if no activityThis label marks the issue/pr stale - to be closed automatically if no activitystat:awaiting responseStatus - Awaiting response from authorStatus - Awaiting response from authortype:bugBugBug