问题类型
支持
你是否在TF nightly版本中复现了这个bug?
否
来源
源代码
Tensorflow版本
tf 2.11.0
自定义代码
是
OS平台和发行版
Windows 11
移动设备
- 无响应*
Python版本
3.7.16
Bazel版本
- 无响应*
GCC/编译器版本
- 无响应*
CUDA/cuDNN版本
- 无响应*
GPU型号和内存大小
- 无响应*
当前行为?
Code doesn't work correctly.
独立代码以重现问题
import tensorflow as tf
import numpy as np
class test:
def __init__(self):
self.counter=None
def sum_func(self):
if np.sum(self.counter)==1875:
return True
@tf.function
def tf_func(self):
flag=self.sum_func()
return flag
def counter_func(self):
while True:
for i in range(1875):
if i==0:
self.counter=np.array(1)
else:
self.counter=np.append(self.counter,np.array(1))
flag=self.tf_func()
if flag==True:
return
t=test()
t.counter_func()
相关日志输出
- 无响应*
2条答案
按热度按时间svmlkihl1#
我能够在 TF 2.11 中重现这个问题。请查看以下代码片段:
drnojrws2#
实际上,tf_func()只被调用一次,但我想保留@tf.function。here