majianjia / nnom

A higher-level Neural Network library for microcontrollers.
Apache License 2.0
815 stars 235 forks source link

Exception with Tensorflow 2.16 #217

Closed jonnor closed 3 months ago

jonnor commented 3 months ago

Hi, I tested NNoM with the latest Tensorflow/Keras 2.x, currently at version 2.16.1

I ran the auto_test example. On TF 2.16.1 I get the following exception:

Traceback (most recent call last):
  File "/home/jon/projects/embeddedml/handson/nnom-models/nnom/examples/auto_test/main.py", line 162, in <module>
    main()
  File "/home/jon/projects/embeddedml/handson/nnom-models/nnom/examples/auto_test/main.py", line 134, in main
    scores = evaluate_model(model, x_test, y_test)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jon/projects/embeddedml/handson/nnom-models/nnom/scripts/nnom.py", line 1098, in evaluate_model
    bs = model.input.shape[0]
         ^^^^^^^^^^^^^^^^^
AttributeError: 'list' object has no attribute 'shape'

I then tried older versions, and they do not have this issue.

TF 2.12.1 - works TF 2.14.1 - works

Hope this information can be useful to someone else :)

jonnor commented 3 months ago

I tried replacing all instances of model.input with model.input[0], and layer.inbound_nodes with layer._inbound_nodes. Then get exception AttributeError: 'Node' object has no attribute 'inbound_layers' which I did not immediately find an obvious fix for. So there is some work needed for Tensorflow 2.16 compatibility

jonnor commented 3 months ago

Ah, I see now that Tensorflow 2.16 pulls in Keras 3.x. So this is duplicate of #214