本文整理汇总了Python中maskrcnn_benchmark.data.samplers.IterationBasedBatchSampler方法的典型用法代码示例。如果您正苦于以下问题:Python samplers.IterationBasedBatchSampler方法的具体用法?Python samplers.IterationBasedBatchSampler怎么用?Python samplers.IterationBasedBatchSampler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类maskrcnn_benchmark.data.samplers
的用法示例。
在下文中一共展示了samplers.IterationBasedBatchSampler方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_number_of_iters_and_elements
# 需要导入模块: from maskrcnn_benchmark.data import samplers [as 别名]
# 或者: from maskrcnn_benchmark.data.samplers import IterationBasedBatchSampler [as 别名]
def test_number_of_iters_and_elements(self):
for batch_size in [2, 3, 4]:
for num_iterations in [4, 10, 20]:
for drop_last in [False, True]:
dataset = [i for i in range(10)]
sampler = SequentialSampler(dataset)
batch_sampler = BatchSampler(
sampler, batch_size, drop_last=drop_last
)
iter_sampler = IterationBasedBatchSampler(
batch_sampler, num_iterations
)
assert len(iter_sampler) == num_iterations
for i, batch in enumerate(iter_sampler):
start = (i % len(batch_sampler)) * batch_size
end = min(start + batch_size, len(dataset))
expected = [x for x in range(start, end)]
self.assertEqual(batch, expected)