本文整理匯總了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)