0

I want to update a convolutional filter using matlab in Caffe. How can I do it? so far my code is:

caffe.reset_all(); % reset caffe
caffe.set_mode_gpu();
gpu_id = 0;  % we will use the first gpu in this demo
caffe.set_device(gpu_id);

net_model = [model_dir, 'train_images.prototxt'];
net = caffe.Net(net_model, 'train');

net.blobs('conv1').set_data([1,1,0]);
user570593
  • 3,420
  • 12
  • 56
  • 91

1 Answers1

0

The following works fine.

caffe.reset_all(); % reset caffe
caffe.set_mode_gpu();  
gpu_id = 0;  % we will use the first gpu in this demo    
caffe.set_device(gpu_id);
net_model = ['net_images.prototxt'];
net = caffe.Net(net_model, 'train')
a = zeros(1,1,3,2);
a(1,1,:,:) = [[1,0,0];[0,1,0]]'; % caffe uses BGR color channel order
         net.layers('select_B_G').params(1).set_data(a);
solver = caffe.Solver(solverFN);
solver.solve();
net.save(fullfile(model_dir, 'my_net.caffemodel'));
user570593
  • 3,420
  • 12
  • 56
  • 91