How to debug forward function in class?

In the past few weeks, I have been wondering how to debug the forward forward propagation function in a certain class. I finally figured it out today, and recorded it (when debugging the function before, even if the breakpoint was interrupted under the forward function, it would still be displayed during debugging. directly into the __init__ function in the class...)

For example, YOLOX code, want to see the data in the forward function in the YOLOHead class:

1. First find the place where the class is called, YOLOHead is called by YoloBody, and YoloBody is called on trian.py:

So be sure to press the debug button on trian.py, and don't use breakpoints here!

2. Break the breakpoint under the forward function of the YoloBody class. Be careful not to hit the breakpoint directly on the function or class name, because self.backbone=YOLOPAFPN(), so when running to the self.backbone.forward(x) statement, Will call YOLOPAFPN class

 3. When the program runs to the YOLOPAFPN class, set a breakpoint on the statement below the forward function, click the Step into of the debug button at this time, do not click Step Over, and you can view the call of the forward function!

 

 

Guess you like

Origin blog.csdn.net/weixin_44570845/article/details/129913907