Sergey
Sergey

Reputation: 4752

Setting batch_size in data_param for Caffe has no effect

When I set 'batch_size' in deploy.prototxt file in Google deep dream bvlc_googlenet to lower GPU memory requirements, it has no effect on speed nor memory requirements. It's as if it was ignored. I know the file itself (deploy.prototxt) is being used because other changes are reflected in results so that's not the issue. I also tried to set batch_size on all related layers as well ("inception_4c/1x1", etc), again no difference.

This is how I'm setting it:

layer {
  name: "inception_4c/output"
  type: "Concat"
  bottom: "inception_4c/1x1"
  bottom: "inception_4c/3x3"
  bottom: "inception_4c/5x5"
  bottom: "inception_4c/pool_proj"
  top: "inception_4c/output"
  data_param {
    batch_size 1
  }
}

When I time the runtime of the script, it's the same with batch_size 1 and with batch_size 512, there is no difference.

What am I doing wrong?

Upvotes: 0

Views: 2208

Answers (1)

Shai
Shai

Reputation: 114816

data_param is a parameter of the input data layer. You can set batch_size only for the input and this value propagates through the network.

In the deploy.prototxt the batch size is set by the first 'input_dim' argument (third line), try changing this value and see if it has any effect on the memory consumption of your network.

The first few lines of the deploy.prototxt file should be interpreted as

input: "data"  # the "top" name of input layer
input_dim: 10  # 4th dimension - batch size
input_dim: 3   # 3rd dimension - number of channels
input_dim: 224 # 2nd dimension - height of input
input_dim: 224 # 1st dimension - width of input

Thus, you expect at your fist conv layer ("conv1/7x7_s2") a "bottom" named "data" with shape 10-by-3-by-224-by-224.

Upvotes: 0

Related Questions