diff --git a/python/paddle/batch.py b/python/paddle/batch.py index d48c54fcbb66487617b1946bc69724870c8f879c..2ba45c8164602e3d090d158741cf4e94f8af6b9f 100644 --- a/python/paddle/batch.py +++ b/python/paddle/batch.py @@ -40,4 +40,9 @@ def batch(reader, batch_size, drop_last=False): if drop_last == False and len(b) != 0: yield b + # Batch size check + if batch_size <= 0: + raise ValueError("batch_size should be a positive integeral value, " + "but got batch_size={}".format(batch_size)) + return batch_reader