From d04f49a835a023d10377284172d25843b607a68c Mon Sep 17 00:00:00 2001 From: x54-729 <17307130121@fudan.edu.cn> Date: Tue, 26 Apr 2022 05:33:17 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9BucketedBatchSampler=20batch?= =?UTF-8?q?=5Fidx=5Fin=5Fepoch=20=E7=9A=84=E8=AE=A1=E7=AE=97=E6=96=B9?= =?UTF-8?q?=E5=BC=8F=EF=BC=8C=E4=BD=BF=E5=85=B6=E5=9C=A8=E5=88=86=E5=B8=83?= =?UTF-8?q?=E5=BC=8F=E6=9D=A1=E4=BB=B6=E4=B8=8B=E5=8F=AF=E4=BB=A5=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=E5=9C=B0=E5=8F=8D=E5=BA=94=E8=BF=AD=E4=BB=A3=E6=AC=A1?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fastNLP/core/samplers/reproducible_batch_sampler.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fastNLP/core/samplers/reproducible_batch_sampler.py b/fastNLP/core/samplers/reproducible_batch_sampler.py index e8acc645..2bbf409f 100644 --- a/fastNLP/core/samplers/reproducible_batch_sampler.py +++ b/fastNLP/core/samplers/reproducible_batch_sampler.py @@ -416,7 +416,7 @@ class BucketedBatchSampler(ReproducibleBatchSampler): @property def batch_idx_in_epoch(self): if self.drop_last: - return len(self.dataset) // self.batch_size - (len(self.dataset) - self.num_consumed_samples) // self.batch_size + return len(self.dataset) // self.num_replicas // self.batch_size - self.num_left_samples // self.batch_size else: - return (len(self.dataset) + self.batch_size - 1) // self.batch_size - \ - (len(self.dataset) - self.num_consumed_samples + self.batch_size - 1) // self.batch_size \ No newline at end of file + return (len(self.dataset) // self.num_replicas + self.batch_size - 1) // self.batch_size - \ + (self.num_left_samples + self.batch_size - 1) // self.batch_size \ No newline at end of file