how to do regression with a multi task Eulidean loss?

273 views
Skip to first unread message

Majid Azimi

unread,
Mar 8, 2016, 9:51:22 AM3/8/16
to Caffe Users

Hi,


I would like to do regression using caffe for training a network which predicts optic flow magnitude map and optic flow direction map of an image (not two) using a multitask EuclideanLoss. the ground truth is a grayscale magnitude optic flow and 2D vector of optic flow. 


To predict those maps, I modified AlexNet fully connected layers to fully convolutional and in the end defined two EuclideanLosses. could you let me know how to do regression in this case? and another question is basically how to specify the dimensions of output that is for vector optic flow prediction, it has two channels. x and y with the same size as image and another 1 channel output for flow magnitude.

########################################train_val.prototxt is
name: "FCN-FlowRegressionCaffeNet"
########## I didn't get it how to use this layer and how to make those training data into list.txt

layer {
name: "data"
type: "HDF5_DATA"
top: "data"
top: "magnitude_labels"
top: "vector_labels"
include {
phase: TRAIN
}
hdf5_data_param {
source: "../list.txt"
batch_size: 128
}

}

......

......
......

layer {
name: "fc7-conv"
type: "Convolution"
bottom: "fc6-conv"
top: "fc7-conv"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 4096
kernel_size: 1
weight_filler {
type: "gaussian"
std: 0.005
}
bias_filler {
type: "constant"
value: 1
}
}

layer {
name: "magnitude"
type: "Convolution"
bottom: "fc7-conv"
top: "magnitude"
param {
lr_mult: 1
}
param {
lr_mult: 2
}
convolution_param {
num_output: 1 #???
kernel_size:1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "vector"
type: "Convolution"
bottom: "fc7-conv"
top: "vector"
param {
lr_mult: 1
}
param {
lr_mult: 2
}
convolution_param {
num_output: 1 #####??
kernel_size:1
weight_filler {
type: "gaussian"
std: 0.001
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "accuracyMagnitude"
type: "Accuracy"
bottom: "magnitude"
bottom: "magnitude_labels"
top: "accuracy"
include {
phase: TEST
}
}
layer {
name: "accuracyVector"
type: "Accuracy"
bottom: "vector"
bottom: "vector_labels"
top: "accuracy"
include {
phase: TEST
}
}

layer {
name: "loss_magnitude"
type: "EuclideanLoss #"type: "SoftmaxWithLoss"
bottom: "magnitude"
bottom: "magnitude_labels"
propagate_down: 1
propagate_down: 0
top: "loss_magnitude"
loss_weight: 1
}
layer {
name: "loss_vector"
type: "EuclideanLoss" #type: "SmoothL1Loss" Euclidean loss instead of softmaxwithloss and L1 loss
bottom: "vector"
bottom: "vector_labels"
top: "loss_vector"
loss_weight: 1
}

########################################## the deploy.prototxt:

name: "AlexNet"
input: "data"
input_shape {
dim: 10
dim: 3
dim: 227
dim: 227
}
layer {
name: "conv1"
.

.

.

layer {
name: "prob"
type: "Softmax" ????
bottom: "magnitude-labels"
top: "prob"
}
layer {
name: "prob"
type: "Softmax" ????
bottom: "vector-labels"
top: "prob"
}


Thanks a lot already for your help.

Majid Azimi

unread,
Mar 8, 2016, 9:56:49 AM3/8/16
to Caffe Users
in the last part of deploy file, magnitude-labels and vector labels are last layer "magnitude" and "vector" layers with no labels. (bad naming )  
Reply all
Reply to author
Forward
0 new messages