Caffe: CHECKs vs. Exceptions

Created on 26 Aug 2015  路  4Comments  路  Source: BVLC/caffe

Should we CHECK or throw to handle errors in Caffe and how could we make the transition? See #1683 for discussion (closed since the dev branch is deprecated).

Python

Most helpful comment

I'd like to cast my vote for moving to throwing exceptions. As a writer of GUI applications, it's the worst when demo'ing a product to a customer and have a full application crash because I mismatched loading the weights of a network and the correct description.

All 4 comments

See h5py for a good example of C exceptions turned into python exceptions:

Traceback (most recent call last):
  File "./create_db.py", line 643, in <module>
    lmdb_map_size   = args['lmdb_map_size']
  File "./create_db.py", line 148, in create_db
    mean_files, **kwargs)
  File "./create_db.py", line 289, in _create_hdf5
    _write_batch_hdf5(db, batch)
  File "./create_db.py", line 530, in _write_batch_hdf5
    db['data'].resize(data_batch.shape)
  File "/usr/lib/python2.7/dist-packages/h5py/_hl/dataset.py", line 277, in resize
    self.id.set_extent(size)
  File "h5d.pyx", line 267, in h5py.h5d.DatasetID.set_extent (h5py/h5d.c:3597)
ValueError: unable to set extend dataset (Dataset: Unable to initialize object)

I'd like to cast my vote for moving to throwing exceptions. As a writer of GUI applications, it's the worst when demo'ing a product to a customer and have a full application crash because I mismatched loading the weights of a network and the correct description.

As a pointer, in case it got into oblivion, we've continued to update our scheme from #1683, you can track changes here: https://github.com/beniz/caffe/commits/master_dd_integ?author=beniz in case it is useful to you... cc @dtmoodie

On this branch of ours, CaffeErrorException is thrown upon most missed CHECK.

Was this page helpful?
0 / 5 - 0 ratings