plugin_event_accumulator_test.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:tensorboard 作者: tensorflow 项目源码 文件源码
def testEventsDiscardedPerTagAfterRestartForFileVersionLessThan2(self):
    """Tests that event discards after restart, only affect the misordered tag.

    If a step value is observed to be lower than what was previously seen,
    this should force a discard of all previous items that are outdated, but
    only for the out of order tag. Other tags should remain unaffected.

    Only file versions < 2 use this out-of-order discard logic. Later versions
    discard events based on the step value of SessionLog.START.
    """
    warnings = []
    self.stubs.Set(tf.logging, 'warn', warnings.append)

    gen = _EventGenerator(self)
    acc = ea.EventAccumulator(gen)

    gen.AddEvent(tf.Event(wall_time=0, step=0, file_version='brain.Event:1'))
    gen.AddScalarTensor('s1', wall_time=1, step=100, value=20)
    gen.AddScalarTensor('s2', wall_time=1, step=101, value=20)
    gen.AddScalarTensor('s1', wall_time=1, step=200, value=20)
    gen.AddScalarTensor('s2', wall_time=1, step=201, value=20)
    gen.AddScalarTensor('s1', wall_time=1, step=300, value=20)
    gen.AddScalarTensor('s2', wall_time=1, step=301, value=20)
    gen.AddScalarTensor('s1', wall_time=1, step=101, value=20)
    gen.AddScalarTensor('s3', wall_time=1, step=101, value=20)
    gen.AddScalarTensor('s1', wall_time=1, step=201, value=20)
    gen.AddScalarTensor('s1', wall_time=1, step=301, value=20)

    acc.Reload()
    ## Check that we have discarded 200 and 300 for s1
    self.assertEqual([x.step for x in acc.Tensors('s1')], [100, 101, 201, 301])

    ## Check that s1 discards do not affect s2 (written before out-of-order)
    ## or s3 (written after out-of-order).
    ## i.e. check that only events from the out of order tag are discarded
    self.assertEqual([x.step for x in acc.Tensors('s2')], [101, 201, 301])
    self.assertEqual([x.step for x in acc.Tensors('s3')], [101])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号