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

github.com/torch/image.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSoumith Chintala <soumith@gmail.com>2016-09-13 17:46:49 +0300
committerGitHub <noreply@github.com>2016-09-13 17:46:49 +0300
commitaa635cfddb4cf53fd37841b7fc827f48343cfee7 (patch)
tree1036c5e2a64557f8217ba33f2267f167f8856820
parenta7af1af68cb76b48d398329164d22fcb799ed3b6 (diff)
parentf94245b0019c3fd1b6d2bbfc836e08f9e90b64b8 (diff)
Merge pull request #189 from qureai/master
Fixed tensor type issue in affinetransform and warp
-rw-r--r--init.lua6
1 files changed, 4 insertions, 2 deletions
diff --git a/init.lua b/init.lua
index 7f15fd5..619d9b7 100644
--- a/init.lua
+++ b/init.lua
@@ -952,6 +952,7 @@ local function warp(...)
dok.error('Incorrect arguments (clamp_mode is not clamp | pad)!', 'image.warp')
end
+ local field = field:typeAs(torch.Tensor()) -- coerce matrix to default tensor type
local dim2 = false
if src:nDimension() == 2 then
dim2 = true
@@ -1065,14 +1066,15 @@ local function affinetransform(...)
local grid_y = torch.ger( torch.linspace(-1,1,height), torch.ones(width) )
local grid_x = torch.ger( torch.ones(height), torch.linspace(-1,1,width) )
- local grid_xy = torch.FloatTensor()
+ local grid_xy = torch.Tensor()
grid_xy:resize(2,height,width)
grid_xy[1] = grid_y * ((height-1)/2) * -1
grid_xy[2] = grid_x * ((width-1)/2) * -1
local view_xy = grid_xy:reshape(2,height*width)
+ local matrix = matrix:typeAs(torch.Tensor()) -- coerce matrix to default tensor type
local field = torch.mm(matrix, view_xy)
- field = (grid_xy - field:reshape( 2, height, width )):double()
+ field = (grid_xy - field:reshape( 2, height, width ))
-- offset field for translation
translation = torch.Tensor(translation)