0

I have a fully convotuional network for depth estimation like this: (only upper and lower layers for the sake of simplicity):

# input: image and depth_image
layer {
  name: "train-data"
  type: "Data"
  top: "data"
  top: "silence_1"
  include {
    phase: TRAIN
  }
  transform_param {
    #mean_file: "mean_train.binaryproto"
    scale: 0.00390625
  }
  data_param {
        source: "/train_lmdb"
    batch_size: 4
    backend: LMDB
  }
}
layer {
  name: "train-depth"
  type: "Data"
  top: "depth"
  top: "silence_2"
  include {
    phase: TRAIN
  }
  transform_param {
    scale: 0.00390625
  }
  data_param {
    source: "train_depth_lmdb"
    batch_size: 4
    backend: LMDB
  }
}
layer {
  name: "val-data"
  type: "Data"
  top: "data"
  top: "silence_1"
  include {
    phase: TEST
  }
  transform_param {
    #mean_file: "mean_val.binaryproto"
    scale: 0.00390625
  }
  data_param {
    source: "val_lmdb"
    batch_size: 4
    backend: LMDB
  }
}
layer {
  name: "val-depth"
  type: "Data"
  top: "depth"
  top: "silence_2"
  include {
    phase: TEST
  }
  transform_param {
    scale: 0.00390625
  }
  data_param {
    source: "val_depth_lmdb"
    batch_size: 4
    backend: LMDB
  }
}
################## Silence unused labels ##################
layer {
    name: "silence_layer_1"
    type: "Silence"
    bottom: "silence_1"
}

layer {
    name: "silence_layer_2"
    type: "Silence"
    bottom: "silence_2"
}
....
layer {
    name: "conv"
    type: "Convolution"
    bottom: "concat"
    top: "conv"
    convolution_param {
        num_output: 1
        kernel_size: 5
        pad: 2
        stride: 1
        engine: CUDNN
        weight_filler {
            type: "gaussian"
            std: 0.01
        }
        bias_filler {
            type: "constant"
            value: 0
        }
    }
}

layer {
    name: "relu"
    type: "ReLU"
    bottom: "conv"
    top: "result"
    relu_param{
    negative_slope: 0.01
        engine: CUDNN
    }
}

# Error
layer {
  name: "accuracy"
  type: "Accuracy"
  bottom: "result"
  bottom: "depth"
  top: "accuracy"
  include {
    phase: TEST
  }
}
layer {
  name: "loss"
  type: "EuclideanLoss"
  bottom: "result"
  bottom: "depth"
  top: "loss"
}

Now I have 3 questions:

When I am training the network the accuracy layer is always 1. I do not understand why?

Is EuclideanLayer the correct layer for this purpose?

Is the mean needed in such a case or can I neglect the mean?

#Define image transformers
transformer = caffe.io.Transformer({'data': net.blobs['data'].data.shape})
transformer.set_mean('data', mean_array)
transformer.set_transpose('data', (2,0,1))

image = "test.png"

img = caffe.io.load_image(image, False)

img = caffe.io.resize_image( img, (IMAGE_WIDTH, IMAGE_HEIGHT))

net.blobs['data'].data[...] = transformer.preprocess('data', img)

pred = net.forward()

output_blob = pred['result']
Shai
  • 111,146
  • 38
  • 238
  • 371

1 Answers1

1
  1. Accuracy is always 1 - see this answer.
  2. "EuclideanLoss" layer is a good fit for regression.
  3. Subtracting the mean should help the net converge better. Keep using it. You can read more about the importance of data normalization and what can be done in that respect here.
Community
  • 1
  • 1
Shai
  • 111,146
  • 38
  • 238
  • 371
  • My problem is, if I use the mean I get black images as output. –  Nov 07 '16 at 13:00
  • all zero images? @thigi – Shai Nov 07 '16 at 13:04
  • Yes, it is really weird. I will add my prediction.py for you. All the output values for my prediction get negative if I use the mean. –  Nov 07 '16 at 13:09
  • @thigi obviously, if you didn't subtract the mean during training, then you don't need to do so when testing. – Shai Nov 07 '16 at 13:25
  • I did subtract during the training by setting the mean_file parameter. It is just as a comment cause I tested sth –  Nov 07 '16 at 13:27
  • Could it be a problem since I use scale that there is something wrong with the mean? I am use scale to get values from [0, 1] (for Euclidean loss). –  Nov 07 '16 at 13:48