Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement new python loss layer error #103

Open
elysion122 opened this issue Dec 12, 2017 · 0 comments
Open

implement new python loss layer error #103

elysion122 opened this issue Dec 12, 2017 · 0 comments

Comments

@elysion122
Copy link

elysion122 commented Dec 12, 2017

Issue summary

I try implement a python loss layer in video-caffe-refactor, but it seems that the blob in python layer is still 4-N.
The python Layer is like this:
class MSSSIM(caffe.Layer):
"A loss layer that calculates (1-MSSSIM) loss. Assuming bottom[0] is output data and bottom[1] is label, meaning no back-propagation to bottom[1]."

def setup(self, bottom, top):
    params = eval(self.param_str)
    self.C1 = params.get('C1', 0.01) ** 2
    self.C2 = params.get('C2', 0.03) ** 2
    self.sigma = params.get('sigma', (0.5, 1., 2., 4., 8.))

    # check input pair
    if len(bottom) != 2:
        raise Exception("Need two inputs to compute distance.")

    if (bottom[0].width%2) != 1 or (bottom[1].width%2) != 1 :
        raise Exception("Odd patch size preferred")

.....

the error is like this:

Creating layer loss
I1208 15:46:54.000308 22662 net.cpp:100] Creating Layer loss
I1208 15:46:54.000342 22662 net.cpp:434] loss <- sum
I1208 15:46:54.000352 22662 net.cpp:434] loss <- label-1
I1208 15:46:54.000362 22662 net.cpp:408] loss -> loss
{'alpha':0.1}
F1208 15:46:54.000448 22662 blob.hpp:140] Check failed: num_axes() <= 4 (5 vs. 4) Cannot use legacy accessors on Blobs with > 4 axes.
*** Check failure stack trace: ***
@ 0x7f0030c83daa (unknown)
@ 0x7f0030c83ce4 (unknown)
@ 0x7f0030c836e6 (unknown)
@ 0x7f0030c86687 (unknown)
@ 0x7f00312bec1c caffe::Blob<>::LegacyShape()
@ 0x7effee812cc6 boost::python::objects::caller_py_function_impl<>::operator()()
@ 0x7f002fb5b64a (unknown)
@ 0x7f002fb5b9b8 (unknown)
@ 0x7f002fb65c93 (unknown)
@ 0x7f002fb5a2c3 (unknown)
@ 0x7f002f783dc3 PyObject_Call
@ 0x7f002f78708c PyObject_CallFunction
@ 0x7f002f7cf0cb _PyObject_GenericGetAttrWithDict
@ 0x7f002f832765 PyEval_EvalFrameEx
@ 0x7f002f8381ce PyEval_EvalCodeEx
@ 0x7f002f7b37e1 function_call
@ 0x7f002f783dc3 PyObject_Call
@ 0x7f002f79654f instancemethod_call
@ 0x7f002f783dc3 PyObject_Call
@ 0x7f002f82dd63 PyEval_CallObjectWithKeywords
@ 0x7f002f853aca PyEval_CallFunction
@ 0x7effee81c3d4 caffe::PythonLayer<>::LayerSetUp()
@ 0x7f0031407a66 caffe::Net<>::Init()
@ 0x7f0031408905 caffe::Net<>::Net()
@ 0x7f00312aecfa caffe::Solver<>::InitTrainNet()
@ 0x7f00312afdfc caffe::Solver<>::Init()
@ 0x7f00312b012a caffe::Solver<>::Solver()
@ 0x7f003145cf43 caffe::Creator_SGDSolver<>()
@ 0x40f56d caffe::SolverRegistry<>::CreateSolver()
@ 0x408664 train()
@ 0x405f3c main
@ 0x7f002f180ec5 (unknown)

How can I use python loss layer with 5-N blob?
Thank you.

@elysion122 elysion122 changed the title implement new implement new python loss layer error Dec 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant