Keras, Tensorflow: How to set breakpoint (debug) in custom layer when evaluating?

后端 未结 2 1508
情书的邮戳
情书的邮戳 2021-01-05 03:02

I just want to do some numerical validation inside the custom layer.

Suppose we have a very simple custom layer:

class test_layer(keras.layers.Layer         


        
2条回答
  •  生来不讨喜
    2021-01-05 03:23

    1. Yes. The call() method is only used to build the computational graph.

    2. As to the debug. I prefer using TFDBG, which is a recommended debugging tool for tensorflow, although it doesn't provide break point functions.

    For Keras, you can add these line to your script to use TFDBG

    import tf.keras.backend as K
    from tensorflow.python import debug as tf_debug
    sess = K.get_session()
    sess = tf_debug.LocalCLIDebugWrapperSession(sess)
    K.set_session(sess)
    

提交回复
热议问题