Added helper function for caffe.