Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

some bugs of transform.merge() #81

Closed
ZongweiZhou1 opened this issue Apr 26, 2017 · 1 comment
Closed

some bugs of transform.merge() #81

ZongweiZhou1 opened this issue Apr 26, 2017 · 1 comment

Comments

@ZongweiZhou1
Copy link

when i run the provided example of transform.merge():

f = transform.merge{
        [1] = function(x) return 2*x end,
        [2] = function(x) return x + 10 end,
        foo = function(x) return x / 2 end,
        [4] = function(x) return x - x end
   }
f(3)

there is always the error information:

...hou/torch/install/share/lua/5.1/torchnet/utils/table.lua:123: attempt to index a number value

i find that the function 'f()' call the function 'utils.table.mergetensor(newz)', and then the line 123 of utils.table attempt to operate 'newz[1]:size()', but here the newz[1] is a number,thus the conflict is produced.

maybe the line 144 can be fixed as 'return newz' ?

@lvdmaaten
Copy link
Contributor

You should never use a table with text keys as input into transform.merge: such a hashtable has no guarantees on the order of elements when you iterate over it with pairs(), making the behavior of your example undefined. Please use a table with numerical indexes (a table you can iterate over with ipairs()) instead.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants