在 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.

相关文章:

  • 2021-12-12
  • 2022-12-23
  • 2021-05-29
  • 2021-10-04
  • 2021-06-16
  • 2022-12-23
  • 2021-07-26
  • 2021-04-01
猜你喜欢
  • 2021-05-01
  • 2021-12-05
  • 2021-09-24
  • 2021-07-11
  • 2022-12-23
  • 2021-11-23
  • 2022-12-23
相关资源
相似解决方案