TensorFlow 建立多个模型导致的运行过慢问题

在 TensorFlow 里,如果反复编译调度多个模型,代码的运行速度会越来越慢。应该及时调用 tf.keras.backend.clear_session()进行资源释放。官方说明如下:

If you are creating many models in a loop, this global state will consume an increasing amount of memory over time, and you may want to clear it. Calling clear_session() releases the global state: this helps avoid clutter from old models and layers, especially when memory is limited.

Original: https://www.cnblogs.com/yaos/p/14021299.html
Author: 2021年的顺遂平安君
Title: TensorFlow 建立多个模型导致的运行过慢问题





最近整理资源【免费获取】:   👉 程序员最新必读书单  | 👏 互联网各方向面试题下载 | ✌️计算机核心资源汇总