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 Chintala <soumith@gmail.com>2015-07-31 18:58:59 +0300
committerSoumith Chintala <soumith@gmail.com>2015-07-31 18:58:59 +0300
commit84df43bbabd7f5330dccfa058c37b404d0cd85bf (patch)
treee2343782126bcc36ed3731d63b2020e867a15999
parent4b880a6a74a84c164fb3e67c588b837f1babce44 (diff)
parentb7b4a1558418d5999b9149f3e4dfdff27a6fa773 (diff)
Merge pull request #339 from torch/singletondim
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)