tensorflow / decision-forests

A collection of state-of-the-art algorithms for the training, serving and interpretation of Decision Forest models in Keras.
Apache License 2.0
660 stars 110 forks source link

Error while convering tensor flow decision forests td model into TFlite model #219

Closed FangTracy closed 4 months ago

FangTracy commented 5 months ago

when i use below lines to convert the randomforest model to tflite format:

model = tfdf.keras.RandomForestModel()
model.fit(train_ds)

converter = tf.lite.TFLiteConverter.from_keras_model(model) tflite_model = converter.convert()

it reports below errors:

Compiling model... Model compiled. [INFO 24-05-24 14:52:46.2487 CST kernel.cc:1233] Loading model from path /tmp/tmpi5vb7gdd/assets/ with prefix e1933c10dbc149b1 [INFO 24-05-24 14:52:46.2628 CST decision_forest.cc:734] Model loaded with 300 root(s), 3040 node(s), and 5 input feature(s). [INFO 24-05-24 14:52:46.2633 CST kernel.cc:1061] Use fast generic engine WARNING: All log messages before absl::InitializeLog() is called are written to STDERR W0000 00:00:1716533566.268118 929 tf_tfl_flatbuffer_helpers.cc:390] Ignored output_format. W0000 00:00:1716533566.268394 929 tf_tfl_flatbuffer_helpers.cc:393] Ignored drop_control_dependency. 2024-05-24 14:52:46.269824: I tensorflow/cc/saved_model/reader.cc:83] Reading SavedModel from: /tmp/tmpi5vb7gdd 2024-05-24 14:52:46.271376: I tensorflow/cc/saved_model/reader.cc:51] Reading meta graph with tags { serve } 2024-05-24 14:52:46.271517: I tensorflow/cc/saved_model/reader.cc:146] Reading SavedModel debug info (if present) from: /tmp/tmpi5vb7gdd 2024-05-24 14:52:46.282128: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:388] MLIR V1 optimization pass is not enabled 2024-05-24 14:52:46.284642: I tensorflow/cc/saved_model/loader.cc:234] Restoring SavedModel bundle. 2024-05-24 14:52:46.320009: I tensorflow/cc/saved_model/loader.cc:218] Running initialization op on SavedModel bundle at path: /tmp/tmpi5vb7gdd [INFO 24-05-24 14:52:46.3509 CST kernel.cc:1233] Loading model from path /tmp/tmpi5vb7gdd/assets/ with prefix e1933c10dbc149b1 [INFO 24-05-24 14:52:46.3655 CST decision_forest.cc:734] Model loaded with 300 root(s), 3040 node(s), and 5 input feature(s). [INFO 24-05-24 14:52:46.3656 CST kernel.cc:1061] Use fast generic engine 2024-05-24 14:52:46.367187: I tensorflow/cc/saved_model/loader.cc:317] SavedModel load for tags { serve }; Status: success: OK. Took 97381 microseconds. 2024-05-24 14:52:46.396239: I tensorflow/compiler/mlir/tensorflow/utils/dump_mlir_util.cc:268] disabling MLIR crash reproducer, set env var MLIR_CRASH_REPRODUCER_DIRECTORY to enable. loc(fused["SimpleMLCreateModelResource:", "SimpleMLCreateModelResource"]): error: 'tf.SimpleMLCreateModelResource' op is neither a custom op nor a flex op

can the converter be supported ? how to solve the error?

rstz commented 4 months ago

Hi, Converting TF-DF models to TFLite is not supported, see here for more information