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

Expose LayerFactory::LayerTypeList in pycaffe #2930

Merged
merged 1 commit into from
Aug 20, 2015

Conversation

lukeyeager
Copy link
Contributor

I want to be able to validate NetParameters with pycaffe without waiting for Caffe to crash on SIGABRT.

F0814 16:58:06.833762 31396 layer_factory.hpp:80] Check failed: registry.count(type) == 1 (0 vs. 1) Unknown layer type: not-a-layer-type (known types: AbsVal, Accuracy, ArgMax, BNLL, Concat, ContrastiveLoss, Convolution, Data, Deconvolution, Dropout, DummyData, Eltwise, EuclideanLoss, Exp, Filter, Flatten, HDF5Data, HDF5Output, HingeLoss, Im2col, ImageData, InfogainLoss, InnerProduct, LRN, Log, MVN, MemoryData, MultinomialLogisticLoss, PReLU, Pooling, Power, Python, ReLU, Reduction, Reshape, SPP, Sigmoid, SigmoidCrossEntropyLoss, Silence, Slice, Softmax, SoftmaxWithLoss, Split, TanH, Threshold, WindowData)
*** Check failure stack trace: ***
Aborted (core dumped)

Exposing LayerTypeList in pycaffe lets me check the layer types and handle errors in a reasonable way.

Is there any way to catch all CHECK/DCHECK errors with pycaffe and turn them into Python exceptions?

@ronghanghu
Copy link
Member

Look good to me :)


def test_standard_types(self):
for type_name in ['Data', 'Convolution', 'InnerProduct']:
assert type_name in caffe.layer_type_list(), \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should use self.assertTrue(...) instead of assert ... (edit: apparently assertIn is a thing too, should use that)

@jeffdonahue
Copy link
Contributor

LGTM besides above comment.

Useful for validating NetParameters without crashing on SIGABRT
@lukeyeager
Copy link
Contributor Author

Thanks for the review. Changed and squashed. Why is unittest.assertIn() preferable to assert?

Also, can you address this question:

Is there any way to catch all CHECK/DCHECK errors with pycaffe and turn them into Python exceptions?

That would be a huge help.

@jeffdonahue
Copy link
Contributor

Thanks for the update! The unittest.assert* functions will make the test pass/fail appropriately according to their result and print a nicely formatted error message when the assertion fails, where assert will just raise an Exception if its argument is false. (Maybe the exception would also make the test fail, but presumably with a less nice error message.)

Edit: more info here -- apparently a plain AssertionError (as raised by a failing assert) was the old way to signal test failure and will work fine for now, but it may not be supported in the future.

Is there any way to catch all CHECK/DCHECK errors with pycaffe and turn them into Python exceptions?

I think #1683 tried to do this

jeffdonahue added a commit that referenced this pull request Aug 20, 2015
Expose LayerFactory::LayerTypeList in pycaffe
@jeffdonahue jeffdonahue merged commit aa2a6f5 into BVLC:master Aug 20, 2015
@lukeyeager lukeyeager deleted the pycaffe-layer_type_list branch August 20, 2015 18:23
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

Successfully merging this pull request may close these issues.

3 participants