diff --git a/python/caffe/pycaffe.py b/python/caffe/pycaffe.py index a2fb16ba..dde838d6 100644 --- a/python/caffe/pycaffe.py +++ b/python/caffe/pycaffe.py @@ -57,10 +57,10 @@ def _Net_forward(self, blobs=None, **kwargs): # Set input according to defined shapes and make arrays single and # C-contiguous as Caffe expects. for in_, blob in kwargs.iteritems(): - if blob.shape[0] != self.blobs[in_].num: - raise Exception('Input is not batch sized') if blob.ndim != 4: raise Exception('{} blob is not 4-d'.format(in_)) + if blob.shape[0] != self.blobs[in_].num: + raise Exception('Input is not batch sized') self.blobs[in_].data[...] = blob self._forward() @@ -91,10 +91,10 @@ def _Net_backward(self, diffs=None, **kwargs): # Set top diffs according to defined shapes and make arrays single and # C-contiguous as Caffe expects. for top, diff in kwargs.iteritems(): - if diff.shape[0] != self.blobs[top].num: - raise Exception('Diff is not batch sized') if diff.ndim != 4: raise Exception('{} diff is not 4-d'.format(top)) + if diff.shape[0] != self.blobs[top].num: + raise Exception('Diff is not batch sized') self.blobs[top].diff[...] = diff self._backward()