diff options
author | Dominik Grewe <dominikg@google.com> | 2015-07-27 13:03:19 +0300 |
---|---|---|
committer | Dominik Grewe <dominikg@google.com> | 2015-07-27 13:03:19 +0300 |
commit | ace001045b2fdf7a8c2ebe69b7231e6d1c88ee65 (patch) | |
tree | 7df3b2188d05fa6d612cd24655c8dcba7d60f80f /utils.lua | |
parent | 328ce70b76581a4aa0706ede2ca9ee13348c6507 (diff) |
Make addSingletonDimension() more robust and add tests.
Diffstat (limited to 'utils.lua')
-rw-r--r-- | utils.lua | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -66,6 +66,10 @@ function nn.utils.recursiveAdd(t1, val, t2) 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) + local view = t.new() local size = torch.LongStorage(t:dim() + 1) local stride = torch.LongStorage(t:dim() + 1) |