* Resume training from solver snapshots
* Access train net and test nets in a solver
* Run for a certain number of iterations and give back control to Matlab
-* Intermingle arbitrary Matlab code to with gradient steps
+* Intermingle arbitrary Matlab code with gradient steps
-An ILSVRC image classification demo is in caffe/matlab/demo/classification_demo.m
+An ILSVRC image classification demo is in caffe/matlab/demo/classification_demo.m (you need to download BVLC CaffeNet from [Model Zoo](http://caffe.berkeleyvision.org/model_zoo.html) to run it).
### Build MatCaffe
end
end
methods (Test)
+ function self = test_blob(self)
+ self.net.blobs('data').set_data(10 * ones(self.net.blobs('data').shape));
+ self.verifyEqual(self.net.blobs('data').get_data(), ...
+ 10 * ones(self.net.blobs('data').shape, 'single'));
+ self.net.blobs('data').set_diff(-2 * ones(self.net.blobs('data').shape));
+ self.verifyEqual(self.net.blobs('data').get_diff(), ...
+ -2 * ones(self.net.blobs('data').shape, 'single'));
+ original_shape = self.net.blobs('data').shape;
+ self.net.blobs('data').reshape([6 5 4 3 2 1]);
+ self.verifyEqual(self.net.blobs('data').shape, [6 5 4 3 2 1]);
+ self.net.blobs('data').reshape(original_shape);
+ self.net.reshape();
+ end
+ function self = test_layer(self)
+ self.verifyEqual(self.net.params('conv', 1).shape, [2 2 2 11]);
+ self.verifyEqual(self.net.layers('conv').params(2).shape, 11);
+ self.verifyEqual(self.net.layers('conv').type(), 'Convolution');
+ end
function test_forward_backward(self)
self.net.forward_prefilled();
self.net.backward_prefilled();
weights_file = tempname();
self.net.save(weights_file);
model_file2 = caffe.test.test_net.simple_net_file(self.num_output);
- net2 = caffe.Net(model_file2, weights_file, 'train');
+ net2 = caffe.Net(model_file2, 'train');
+ net2.copy_from(weights_file);
+ net3 = caffe.Net(model_file2, weights_file, 'train');
delete(model_file2);
delete(weights_file);
for l = 1:length(self.net.layer_vec)
for i = 1:length(self.net.layer_vec(l).params)
self.verifyEqual(self.net.layer_vec(l).params(i).get_data(), ...
net2.layer_vec(l).params(i).get_data());
+ self.verifyEqual(self.net.layer_vec(l).params(i).get_data(), ...
+ net3.layer_vec(l).params(i).get_data());
end
end
end
self.blobs(self.outputs{n}).set_diff(output_diff{n});
end
self.backward_prefilled();
- % retrieve diff from input_blobs
+ % retrieve diff from input blobs
res = cell(length(self.inputs), 1);
for n = 1:length(self.inputs)
res{n} = self.blobs(self.inputs{n}).get_diff();
function mean_data = read_mean(mean_proto_file)
% mean_data = read_mean(mean_proto_file)
% read image mean data from binaryproto file
- CHECK(ischar(mean_proto_file), 'im_file must be a string');
+ CHECK(ischar(mean_proto_file), 'mean_proto_file must be a string');
CHECK_FILE_EXIST(mean_proto_file);
mean_data = caffe_('read_mean', mean_proto_file);
end