From: philkr Date: Tue, 4 Aug 2015 17:27:34 +0000 (-0700) Subject: ImageData layer default batch size of 1, and check for zero batch size X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e7b2b4eab67390885b8cb360750cfc1553fbb70e;p=platform%2Fupstream%2Fcaffe.git ImageData layer default batch size of 1, and check for zero batch size --- diff --git a/src/caffe/layers/image_data_layer.cpp b/src/caffe/layers/image_data_layer.cpp index 18c035c..dcc5334 100644 --- a/src/caffe/layers/image_data_layer.cpp +++ b/src/caffe/layers/image_data_layer.cpp @@ -62,11 +62,13 @@ void ImageDataLayer::DataLayerSetUp(const vector*>& bottom, // Read an image, and use it to initialize the top blob. cv::Mat cv_img = ReadImageToCVMat(root_folder + lines_[lines_id_].first, new_height, new_width, is_color); + CHECK(cv_img.data) << "Could not load " << lines_[lines_id_].first; // Use data_transformer to infer the expected blob shape from a cv_image. vector top_shape = this->data_transformer_->InferBlobShape(cv_img); this->transformed_data_.Reshape(top_shape); // Reshape prefetch_data and top[0] according to the batch_size. const int batch_size = this->layer_param_.image_data_param().batch_size(); + CHECK_GT(batch_size, 0) << "Positive batch size required"; top_shape[0] = batch_size; this->prefetch_data_.Reshape(top_shape); top[0]->ReshapeLike(this->prefetch_data_); @@ -108,6 +110,7 @@ void ImageDataLayer::InternalThreadEntry() { // on single input batches allows for inputs of varying dimension. cv::Mat cv_img = ReadImageToCVMat(root_folder + lines_[lines_id_].first, new_height, new_width, is_color); + CHECK(cv_img.data) << "Could not load " << lines_[lines_id_].first; // Use data_transformer to infer the expected blob shape from a cv_img. vector top_shape = this->data_transformer_->InferBlobShape(cv_img); this->transformed_data_.Reshape(top_shape); diff --git a/src/caffe/proto/caffe.proto b/src/caffe/proto/caffe.proto index 81a8c69..8c3f072 100644 --- a/src/caffe/proto/caffe.proto +++ b/src/caffe/proto/caffe.proto @@ -290,7 +290,7 @@ message LayerParameter { // The blobs containing the numeric parameters of the layer. repeated BlobProto blobs = 7; - + // Specifies on which bottoms the backpropagation should be skipped. // The size must be either 0 or equal to the number of bottoms. repeated bool propagate_down = 11; @@ -431,7 +431,7 @@ message ContrastiveLossParameter { // Hadsell paper. New models should probably use this version. // legacy_version = true uses (margin - d^2). This is kept to support / // reproduce existing models and results - optional bool legacy_version = 2 [default = false]; + optional bool legacy_version = 2 [default = false]; } message ConvolutionParameter { @@ -579,7 +579,7 @@ message ImageDataParameter { // Specify the data source. optional string source = 1; // Specify the batch size. - optional uint32 batch_size = 4; + optional uint32 batch_size = 4 [default = 1]; // The rand_skip variable is for the data layer to skip a few data points // to avoid all asynchronous sgd clients to start at the same point. The skip // point would be set as rand_skip * rand(0,1). Note that rand_skip should not