-
Notifications
You must be signed in to change notification settings - Fork 861
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
MNIST_LSTM example case does not generate proper operators #3048
Comments
After trying many combinations of Python- and library versions, the problem seems to start from TensorFlow 2.16.0. The Release Note for TensorFlow 2.16.0 does not list any breaking changes to the TensorFlow Lite converter. |
@choas Thanks for the reply and suggested fix! # [...]
import os
# Needed for compatibility, default is Keras 3 from Tensorflow 2.16 onwards, this reverts to using Keras 2
os.environ["TF_USE_LEGACY_KERAS"] = "1"
from absl import app
from absl import flags
from absl import logging
import numpy as np
import tensorflow as tf
# [...] With the requirement that Now I just need some time to see if we can update the whole script to use the new Keras 3 API, as that would fix the issue properly. |
[internal notes: script update for legacy Keras -or- test training with concrete function conversion instead of Keras TOCO conversion] |
The MNIST LSTM example does not compile a correct TFLite model with the UnidirectionalSequenceLSTM operator for TFLite Micro. Instead it generates a large graph with many operators.
Versions:
The problem arises when running the
train.py
script with new versions of TensorFlow. Whereas older versions (Python 3.10.x and TensorFlow 2.15.x) would generate the correct TFLite Micro operators, the newer versions output a whole graph of operators (see images below). This change leads to the need to resolve many more operators than before (additional ops:Concatenation, Gather, Less, LogicalAnd, Logistic, Mul, Slice, Split, Tanh and While
). This subsequently makes the final compiled binary to be deployed larger as well.According to the new LiteRT RNN conversion page, the TFLite converter should "provide native support for standard TensorFlow RNN APIs like Keras LSTM". This sadly does not seem to work at the moment.
Is there any TensorFlow syntax that is missing in the example code, or can it be updated to include the needed versions of libraries or Python? Alternatively, can the example code be edited in order to support the new versions of the TensorFlow libraries and Python? Thanks in advance for any help!
The text was updated successfully, but these errors were encountered: