Code for reproducing the bug:
File "/home/zy/PycharmProjects/dl_exchange/auto_ml_kaers.py", line 123, in
pass
File "/home/zy/anaconda3/envs/tf2/lib/python3.6/site-packages/keras/engine/saving.py", line 449, in save_wrapper
save_function(obj, filepath, overwrite, args, *kwargs)
File "/home/zy/anaconda3/envs/tf2/lib/python3.6/site-packages/keras/engine/saving.py", line 541, in save_model
_serialize_model(model, h5dict, include_optimizer)
File "/home/zy/anaconda3/envs/tf2/lib/python3.6/site-packages/keras/engine/saving.py", line 143, in _serialize_model
weight_values = K.batch_get_value(symbolic_weights)
File "/home/zy/anaconda3/envs/tf2/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py", line 2939, in batch_get_value
return tf_keras_backend.batch_get_value(ops)
File "/home/zy/anaconda3/envs/tf2/lib/python3.6/site-packages/tensorflow_core/python/keras/backend.py", line 3270, in batch_get_value
return [x.numpy() for x in tensors]
File "/home/zy/anaconda3/envs/tf2/lib/python3.6/site-packages/tensorflow_core/python/keras/backend.py", line 3270, in
return [x.numpy() for x in tensors]
AttributeError: 'TrackableWeightHandler' object has no attribute 'numpy'
Data used by the code:
clf = ak.StructuredDataClassifier(max_trials=100,name='auto-keras3',overwrite=False,directory='ak/ak3')
clf.fit(x_train, y_train,validation_split=0.15)
predicted_y = clf.predict(x_test)
model=clf.export_model()
save_model(model,model_save_path)
Include the details about the versions of:
I still can't use any of my own datasets to make predictions or save models in structured data. Is this a bug? I haven't seen it repaired for a long time
If applicable, add any other context about the problem.
-->
This is because we implemented our own preprocessing layer for feature encoding. We are soon moving to TF2.2, which has the official layers to do the task. At that time, this should be fixed.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Having the same problem with TF2.2.0, trying to save a model having TextVectorization as first layer.
NotImplementedError: Save or restore weights that is not an instance oftf.Variableis not supported in h5, usesave_format='tf'instead. Got a model or layer TextVectorization with weights [<tensorflow.python.keras.engine.base_layer_utils.TrackableWeightHandler object at 0x7fbcd91b2bb0>]
Our latest tutorial on structured data regression works. It is using tf 2.2.0 ak 1.0.3.
It has no problem exporting the model. As I tested it saves too.
https://autokeras.com/tutorial/structured_data_regression/
Most helpful comment
This is because we implemented our own preprocessing layer for feature encoding. We are soon moving to TF2.2, which has the official layers to do the task. At that time, this should be fixed.