require 'nn'
require 'rnn'
maxzero = 1
if maxzero == 1 then
y_ = torch.Tensor{{1,5,2},{0,5,2},{0,0,0}}
y = torch.Tensor{{2,3,1},{0,5,4},{0,0,0}}
y = torch.Tensor{{2,3,1},{0,5,4},{1,1,1}}
else
y_ = torch.Tensor{{1,5,2},{0,5,2}}
y = torch.Tensor{{2,3,1},{0,5,4}}
end
print(y_,y)
c1 = nn.MSECriterion()
c2 = nn.MaskZeroCriterion(nn.MSECriterion(),1)
o1 = c1:forward(y_,y)
o2 = c2:forward(y_,y)
print(o1,o2)
c3 = nn.DistKLDivCriterion()
c4 = nn.MaskZeroCriterion(nn.DistKLDivCriterion(),1)
o3 = c3:forward(y_,y)
o4 = c4:forward(y_,y)
print(o3,o4)
if maxzero == 1 then
y_ = torch.Tensor{{-1.20397280433,-2.30258509299,-0.51082562376},{-2.30258509299,-0.22314355131,-2.30258509299},{0,0,0}}
y = torch.Tensor{3,2,3}
else
y_ = torch.Tensor{{-1.20397280433,-2.30258509299,-0.51082562376},{-2.30258509299,-0.22314355131,-2.30258509299}}
y = torch.Tensor{3,2}
end
c5 = nn.ClassNLLCriterion()
c6 = nn.MaskZeroCriterion(nn.ClassNLLCriterion(),1)
o5 = c5:forward(y_,y)
o6 = c6:forward(y_,y)
print(o5,o6)