Nima
Nima

Reputation: 433

caffe check failed: kernel_size specified 2 times; 0 spatial dims

I have a caffe "Check failed" error as:

...
I0415 15:35:30.497133 39410 net.cpp:129] Top shape: 1 4096 (4096)
I0415 15:35:30.497135 39410 net.cpp:137] Memory required for data: 2898304
I0415 15:35:30.497138 39410 layer_factory.hpp:77] Creating layer conv1
I0415 15:35:30.497155 39410 net.cpp:84] Creating Layer conv1
I0415 15:35:30.497169 39410 net.cpp:406] conv1 <- ReLU0
I0415 15:35:30.497174 39410 net.cpp:380] conv1 -> conv1
F0415 15:35:30.497185 39410 base_conv_layer.cpp:35] Check failed: num_kernel_dims == 1 || num_kernel_dims == num_spatial_axes_ kernel_size must be specified once, or once per spatial dimension (kernel_size specified 2 times; 0 spatial dims).

and here is a little part of the proto.txt file:

...
layer {
  name: "loss0"
  type: "EuclideanLoss"
  bottom: "ampl0"
  bottom: "label_b4_noise"
  top: "loss0"
}
layer {
  name: "ReLU0"
  type: "ReLU"
  bottom: "ampl0"
  top: "ReLU0"
  relu_param {
    negative_slope: 0
  }
}
layer {
  name: "conv1"
  type: "Convolution"
  bottom: "ReLU0"
  top: "conv1"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  convolution_param {
    num_output: 16
    bias_term: false
    pad: 0
    pad: 0
    kernel_size: 1
    kernel_size: 5
    group: 1
    stride: 1
    stride: 1
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
      value: 0.0
    }
    axis: 1
  }
}
...

could you please tell me why "Check failed"?

what "kernel_size specified 2 times; 0 spatial dims" means?

what num_spatial_axes_ kernel_size is here? sorry if my question is trivial.

Upvotes: 1

Views: 192

Answers (1)

Shai
Shai

Reputation: 114976

Look at the input for your layer ("ReLU0"):

I0415 15:35:30.497133 39410 net.cpp:129] Top shape: 1 4096 (4096)

Its dimensions are 1x4096 that is, it has 1 batch with 4096 channels with no width and no height (that is, width and height are singleton dimensions that are usually ignored).
Now you want to apply "conv1" a 1x5 kernel. How do you want to apply a convolution on a blob that has no spatial dimensions?!

This is the error you got from caffe: you specified 2 spatial dimensions for conv kernel (you specified kernel_size twice) but your input blob has no spatial dimensions at all, that is its num_spatial_axes_==0.

Upvotes: 1

Related Questions