From 350de823fcd43dcdc5948ef869d9ea135e2467a1 Mon Sep 17 00:00:00 2001 From: Sergio Gomez Date: Wed, 3 Jun 2015 10:50:55 +0100 Subject: Add support for negative indices in nn.SplitTable This module can now be used when the total number of dimensions is unknown. --- test.lua | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test.lua') diff --git a/test.lua b/test.lua index 88f6f65..901c36f 100644 --- a/test.lua +++ b/test.lua @@ -2928,6 +2928,13 @@ function nntest.SplitTable() module = nn.SplitTable(d, 2) mytester:asserteq(#module:forward(input), input:size(d+1), "dimension " .. d) end + + -- Negative indices + local module = nn.SplitTable(-3) + local input = torch.randn(3,4,5) + mytester:asserteq(#module:forward(input), 3, "negative index") + local input = torch.randn(2,3,4,5) + mytester:asserteq(#module:forward(input), 3, "negative index (minibatch)") end function nntest.SelectTable() -- cgit v1.2.3