Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/nn.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsoumith <soumith@fb.com>2015-07-31 18:58:02 +0300
committersoumith <soumith@fb.com>2015-07-31 18:58:02 +0300
commitb7b4a1558418d5999b9149f3e4dfdff27a6fa773 (patch)
treee2343782126bcc36ed3731d63b2020e867a15999
parent4b880a6a74a84c164fb3e67c588b837f1babce44 (diff)
fixing corner-case of last dimension in addSingletonDimension
-rw-r--r--utils.lua3
1 files changed, 2 insertions, 1 deletions
diff --git a/utils.lua b/utils.lua
index 4d89568..40cc377 100644
--- a/utils.lua
+++ b/utils.lua
@@ -68,7 +68,8 @@ end
function nn.utils.addSingletonDimension(t, dim)
assert(torch.isTensor(t), "input tensor expected")
local dim = dim or 1
- assert(dim > 0 and dim <= t:dim(), "invalid dimension: " .. dim)
+ assert(dim > 0 and dim <= (t:dim() + 1), "invalid dimension: " .. dim
+ .. '. Tensor is of ' .. t:dim() .. ' dimensions.')
local view = t.new()
local size = torch.LongStorage(t:dim() + 1)