how to insert "Reshape" layer in train_val.prototxt?

548 views
Skip to first unread message

Majid Azimi

unread,
Mar 5, 2016, 9:54:48 AM3/5/16
to Caffe Users
Hi, 

 the following part is the data layer in train.prototxt file in VGG16. there is crop_size:224 which we don't want. I want to reshape my data to this size. so be able to use the imagenet_mean file. there is a reshape layer which you can see below, but the problem is I don't know exactly and how I should put into. I tried between data layer and conv1_1, but if failed due the different sizes.

################### data layer
layer {
  name: "data"
  type: "ImageData"
  top: "data"
  top: "label"
  include {
    phase: TRAIN
  }
  transform_param {
    mirror: true
    crop_size:224
    mean_file: "data/ilsvrc12/imagenet_mean.binaryproto"
  }
  image_data_param {
    source: "data/Blocks/10Btrainaugmented.txt"
    batch_size: 50
    new_height: 256
    new_width: 256
  }

################### reshape layer

 layer {
    name: "reshape"
    type: "Reshape"
    bottom: "data"
    top: "reshape"
    reshape_param {
      shape {
        dim: 1 
        dim: 3
        dim: 224
        dim: 224 
      }
    }
  }

Nam Vo

unread,
Mar 5, 2016, 9:13:57 PM3/5/16
to Caffe Users
What you want is to resize, not reshape.

You can resize the images in the image data layer:
    new_height: 224
    new_width: 224

If you want to do some other weird resizing you'll have to write your own layer

S. Majid Azimi

unread,
Mar 6, 2016, 6:27:20 AM3/6/16
to Nam Vo, Caffe Users
thanks. I got it. in the train_val.prototxt file of VGG16, there is image_crop: 224. does it mean before being resized to 256, the input images are cropped first?
if I resize all of images first manually to 224x224x3, so it means this cropping in the tain_val file doesn't have any affects right?
another way to say: I am going to finetune the alexnet, when I remove crop_image:224 I get an error of not compatibility with the model. I want model to see the whole image without cropping. so I resized all of them to 224 to prevent that. now this cropping doesn't change any thing right? 

--
You received this message because you are subscribed to the Google Groups "Caffe Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to caffe-users...@googlegroups.com.
To post to this group, send email to caffe...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/caffe-users/094a0f3f-5163-4d46-89b5-c2f86be547dd%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages