-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
enhancementNew feature or requestNew feature or requestpreconditionsRefactoring preconditions need to be added.Refactoring preconditions need to be added.
Milestone
Description
The numpy API is not directly compatible with tf.function. The code needs to be restructured first. A first step to deal with this is to make no numpy calls a refactoring precondition. Otherwise, we can get an error after running the refactored code, e.g.:
Traceback (most recent call last):
File "/home/rk1424/git/Python-Subjects/tensorflow-yolov4-tflite/train.py", line 165, in <module>
app.run(main)
File "/home/rk1424/.local/lib/python3.10/site-packages/absl/app.py", line 308, in run
_run_main(main, args)
File "/home/rk1424/.local/lib/python3.10/site-packages/absl/app.py", line 254, in _run_main
sys.exit(main(argv))
File "/home/rk1424/git/Python-Subjects/tensorflow-yolov4-tflite/train.py", line 156, in main
train_step(image_data, target)
File "/home/rk1424/.local/lib/python3.10/site-packages/tensorflow/python/util/traceback_utils.py", line 153, in error_handler
raise e.with_traceback(filtered_tb) from None
File "/tmp/__autograph_generated_filest45satl.py", line 48, in tf__train_step
ag__.converted_call(ag__.ld(tf).print, ('=> STEP %4d/%4d lr: %.6f giou_loss: %4.2f conf_loss: %4.2f prob_loss: %4.2f total_loss: %4.2f' % (ag__.ld(global_steps), ag__.ld(total_steps), ag__.converted_call(ag__.ld(optimizer).lr.numpy, (), None, fscope), ag__.ld(giou_loss), ag__.ld(conf_loss), ag__.ld(prob_loss), ag__.ld(total_loss)),), None, fscope)
NotImplementedError: in user code:
File "/home/rk1424/git/Python-Subjects/tensorflow-yolov4-tflite/train.py", line 99, in train_step *
tf.print("=> STEP %4d/%4d lr: %.6f giou_loss: %4.2f conf_loss: %4.2f "
NotImplementedError: numpy() is only available when eager execution is enabled.
The code for this example is at;
The enclosing function should fail refactoring preconditions.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestpreconditionsRefactoring preconditions need to be added.Refactoring preconditions need to be added.