BVLC / caffe

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

Matcaffe: where is the update() method ? #4758

Open zeakey opened 8 years ago

zeakey commented 8 years ago

Hi guys, I'm using Matlab to feed data to my network and get the network output with net.forward;

then compute loss and gradient manually, and use net.backward(gradient) to do backward pass.

But I find that this will never update the net-parameters, and add force_backward:true to net proto doesn't work.

The psudo code of my implementation is:

solver=caffe.solver('solver.prototxt')
net = solver.net();
output = net.forward(input_data)
loss, gradient = some_tricks(output, label)
net.backward(gradient)

So how to update the network params ???

zeakey commented 8 years ago

@shelhamer @ronghanghu @longjon ~_~help

Noiredd commented 6 years ago

Solver::ApplyUpdate() nor Net::Update() are not exposed beyond C++, meaning Matlab and Python interfaces cannot call them. To make this possible, changes to caffe/matlab/+caffe/private/caffe_.cpp are necessary.

zeakey commented 6 years ago

@Noiredd Yeah, I realized this then. I've converted the private Solver::ApplyUpdate() to public, and then it can be called via Matlab or Python interface.

Noiredd commented 6 years ago

Similar change is being implemented - see #6209 and #6238. Once the master branch has a public ApplyUpdate, the same thing could be implemented for the Matlab interface.

ahndroo commented 6 years ago

@zeakey My knowledge with C++ is pretty limited. When you say you made the Solver::ApplyUpdate() method public, did you simply change that in the sgd_solvers.hpp?

zeakey commented 6 years ago

@ahndroo Yes. Make it public in the root class.