From 29bb23fc92c5b71c0bf8af0b9e580015da9aedda Mon Sep 17 00:00:00 2001 From: shai Date: Tue, 23 Feb 2016 10:42:54 +0200 Subject: [PATCH] removing all references to Blob.num property (that assumes Blob is 4D). Replacing it with accessing Blob.shape[0] - for Blobs with num_axes() != 4 --- python/caffe/pycaffe.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python/caffe/pycaffe.py b/python/caffe/pycaffe.py index 3054110771c..5020ecedb10 100644 --- a/python/caffe/pycaffe.py +++ b/python/caffe/pycaffe.py @@ -98,7 +98,7 @@ def _Net_forward(self, blobs=None, start=None, end=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: + if blob.shape[0] != self.blobs[in_].shape[0]: raise Exception('Input is not batch sized') self.blobs[in_].data[...] = blob @@ -146,7 +146,7 @@ def _Net_backward(self, diffs=None, start=None, end=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: + if diff.shape[0] != self.blobs[top].shape[0]: raise Exception('Diff is not batch sized') self.blobs[top].diff[...] = diff @@ -257,7 +257,7 @@ def _Net_batch(self, blobs): batch: {blob name: list of blobs} dict for a single batch. """ num = len(blobs.itervalues().next()) - batch_size = self.blobs.itervalues().next().num + batch_size = self.blobs.itervalues().next().shape[0] remainder = num % batch_size num_batches = num / batch_size