Closed rkuo2000 closed 3 years ago
After set Optimize=False to convert the model to ccode, I can also run 28x28 MNIST on ESP32 now Here's my Arduino example TinyML_MNIST for your reference.
Where did you find optimize=True
in my tutorials? I already switched to optimize=False
in the latest version of tinymlgen
.
https://eloquentarduino.github.io/2020/01/easy-tinyml-on-esp32-and-arduino/ converter.optimizations = [tf.lite.Optimize.OPTIMIZE_FOR_SIZE] <-- this indicates it needs OPTIMIZED_FOR_SIZE
and
c_code = port(model, pretty_print=True) <-- also in your digits_model.py print(c_code)
The above code did not specify optimize=False, and it will generate a very small code. (my tinymlgen is v0.2 which is the current version)
Thanks, I removed converter.optimizations = [tf.lite.Optimize.OPTIMIZE_FOR_SIZE]
from the post.
tinymlgen
version 0.3
switched to optimize=False
by default
Thanks for your great work !
@eloquentarduino It seems that in 2.4.3 (the latest version currently on 2022.09.02),
c_code = port(model, pretty_print=True) <-- also in your digits_model.py
print(c_code)
does not specify optimize=False, and it will generate a very small code.
Optimization seems to break the exported code. For the moment I will default to optimize=False
I found the fix.
When running tinymlgen, optimize default is True, the generated model file is quite small and cause ESP32 keep aborting.
After I modify digits_model.py to set optimize = False, like below : c_code = port(model, variable_name='digits_model', pretty_print=True, optimize=False) with open('digits_model.h', 'w') as f: print(c_code, file=f)
My Arduino example TinyML_Digit are running on ESP32 now !