0

我正在使用稳定的基线 3及其tensorboard 集成来监控我的模型和设置。我想每次都在张量板上绘制一个标量,标量是在self.step()方法中触发的。我做了一个CustomTensorboardCallback,但问题是回调是由默认的 num_steps 调用的,而不是在触发变量时调用的。如果有人可以帮助我,我将不胜感激。我不太确定如何使用 EventCallback 来实现这种行为

class EventCallback(BaseCallback):
"""
Base class for triggering callback on event.

:param callback: (Optional[BaseCallback]) Callback that will be called
    when an event is triggered.
:param verbose: (int)
"""
def __init__(self, callback: Optional[BaseCallback] = None, verbose: int = 0):
    super(EventCallback, self).__init__(verbose=verbose)
    self.callback = callback
    # Give access to the parent
    if callback is not None:
        self.callback.parent = self
...

def _on_event(self) -> bool:
    if self.callback is not None:
        return self.callback()
    return True
4

0 回答 0