第1种方法:
tensorflow keras call函数不能debug,增加@tf.autograph.experimental.do_not_convert
class MyLoss(tf.keras.losses.Loss):
def __init__(self):
super().__init__()
@tf.autograph.experimental.do_not_convert # breakpoint now recognized with this decorator
def call(self, y_true, y_pred):
mae = tf.abs(y_true - y_pred) # set breakpoint here, debugger stops for tf2.2 only
# breakpoint recognized in tf2.3 with use of @tf.autograph.experimental.do_no_convert decorator
return mae
第2种方法:
安装最新anaconda,旧版本的anaconda存在不支持的情况