From f7c253adf4fb64d58d83b6394651a7ad3b1a6d60 Mon Sep 17 00:00:00 2001 From: Zhen He Date: Wed, 6 Apr 2016 11:35:27 +0100 Subject: [PATCH] Avoiding the index being out of bound Avoiding the index being out of bound when 'num' is divisible by 'N * T' --- util/DataLoader.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/DataLoader.lua b/util/DataLoader.lua index e5e53eab..df8c1c16 100644 --- a/util/DataLoader.lua +++ b/util/DataLoader.lua @@ -24,7 +24,7 @@ function DataLoader:__init(kwargs) self.split_sizes = {} for split, v in pairs(splits) do local num = v:nElement() - local extra = num % (N * T) + local extra = (num - 1) % (N * T) + 1 -- Chop out the extra bits at the end to make it evenly divide local vx = v[{{1, num - extra}}]:view(N, -1, T):transpose(1, 2):clone()