BVLC / caffe

Caffe: a fast open framework for deep learning.
http://caffe.berkeleyvision.org/
Other
34.14k stars 18.67k forks source link

How to port Matlab's Neural Network Toolbox Architecture to Caffe prototxt? #4560

Closed beniroquai closed 8 years ago

beniroquai commented 8 years ago

I guess the title already gives an idea of my problem. I'm still a NN newbie, but I have an idea of the basics like pooling-layer, activation functions, etc.

Problem description:

I have an optimization problem where a complex image (imag/real part) acts as the input. By manipulating a set of parameters (the output) using a particle swarm optimization I have influence on image's quality through an adjustable transfer-function. Goal is to maximize the contrast in the image. Problem is: Each optimization takes 10..30 s. Ideally it would be less than 1s.

New approach: Learn optimization parameters

I take a batch of images, simplify them. This is done by taking the fft2 and segment its spectrum with a circular segmentation. The result is a vector which holds the weights of each of the N-segments (i.e. 48 segments = 4 rings*12 segments). This is done because the optimization process is majorly based on the image's spectra.

The output is the vector which holds the parameters (i.e. 48 parameters) The neural network should learn a rough relationship between the input- and output-vectors from a huge dataset which provides already optimized numbers.

Neural Network in MATLAB

Resulting from the problem above, I have a dataset with i.e.1000 samples where I have an input- and output-vector with 48 input-weights and 48 output-parameters. The easiest way to learn from this dataset was to implement it in MATLAB which has the following form: Generated figure of matlabs neural network configuration. I simply used the nftool and generated a network with 5 hidden layers. The results after training and applying the weights are looking promising.

Porting MATLAB to Caffe Architecture

My goal for now is to port this algorithm to the Caffe framework. I was able to successfully build MATCAFFE which is the matlab frontend of Caffe. But their public-examples don't give me any starting point, how to implement this network in their prototxt structure. Perhaps it's the wrong way to go, because it is no a convolutional network? I'd like to use Caffe, because it's open-source and available for Android - so I could port the trained net easily?!

So my question: How would I implement this network? Is there a good tutorial out there what I was missing?

This (http://stackoverflow.com/questions/15526112/export-a-neural-network-trained-with-matlab-in-other-programming-languages) gave me an idea how to interpret MATLABs NN architecture already, but how would I implement the layers/functions in the caffe-prototxt way?

Any advice? Thank you very much!

PS: I posted this on StackExchange, but later I found it suits better in this forum..sorry!

lzx1413 commented 8 years ago

Maybe you can implete this net with fcn layer in caffe

shelhamer commented 8 years ago

Please ask usage and modeling questions on the mailing list.

From https://github.com/BVLC/caffe/blob/master/CONTRIBUTING.md:

Please do not post usage, installation, or modeling questions, or other requests for help to Issues. Use the caffe-users list instead. This helps developers maintain a clear, uncluttered, and efficient view of the state of Caffe.