class nn.DistanceRatioCriterion has been already assigned a parent class

56 views
Skip to first unread message

Shahnawaz Grewal

unread,
Aug 1, 2017, 5:42:20 AM8/1/17
to torch7

I am a newbie to torch and implementing a work from "Deep Learning Metric Using Triplet Network".  However I am not able to compile the code. I got the following error. 


class nn.DistanceRatioCriterion has been already assigned a parent class

stack traceback:
[C]: in function 'error'
/home/super/torch/install/share/lua/5.1/trepl/init.lua:389: in function 'require'
Main.lua:8: in main chunk
[C]: in function 'dofile'
...uper/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:150: in main chunk
[C]: at 0x00405d50

Can someone help me to resolve this error.  

Tasty Minerals

unread,
Aug 6, 2017, 7:05:42 AM8/6/17
to torch7
Remove "nn" from "nn.DistanceRatioCriterion"

local mycustomClass, parent = torch.class('DistanceRatioCriterion', 'nn.someParentClass')


Francesco App

unread,
Oct 8, 2017, 6:06:10 AM10/8/17
to torch7
Thank you so much Tasty Minerals. After this error, others appeared running TripletNet code from elad. I have an error even in the forward pass (incorrect number of input). I tried to fix things like this:
optimizer file, function Optimizer:optimize(x,yt)
    local y1 = y[{{},{1}}]
    local y2 = y[{{},{2}}]
    local ytable = {y1,y2}
    local dE_dy = self.Loss:backward(ytable)
    self.Model:backward(x, {dE_dy[1][1],dE_dy[1][2]})

but without success. Is anyone able to run TripletNet code on a Sept-2017 torch7 environment? I've tried with cifar10 and cifar100 db. 
Thank you in advance
Francesco
Reply all
Reply to author
Forward
0 new messages