Skip to content
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
before_script:
- sudo apt-add-repository ppa:octave/stable --yes
- sudo apt-get update -y
- sudo apt-get install octave -y
- sudo apt-get install octave --force-yes
- sudo apt-get install liboctave-dev -y
script:
- sh -c "octave tests/runalltests.m"
Expand Down
4 changes: 3 additions & 1 deletion CNN/cnnbp.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
for l = (n - 1) : -1 : 1
if strcmp(net.layers{l}.type, 'c')
for j = 1 : numel(net.layers{l}.a)
net.layers{l}.d{j} = net.layers{l}.a{j} .* (1 - net.layers{l}.a{j}) .* (expand(net.layers{l + 1}.d{j}, [net.layers{l + 1}.scale net.layers{l + 1}.scale 1]) / net.layers{l + 1}.scale ^ 2);
xscale = net.layers{l + 1}.xscale;
yscale = net.layers{l + 1}.yscale;
net.layers{l}.d{j} = net.layers{l}.a{j} .* (1 - net.layers{l}.a{j}) .* (expand(net.layers{l + 1}.d{j}, [xscale yscale 1]) / (xscale*yscale));
end
elseif strcmp(net.layers{l}.type, 's')
for i = 1 : numel(net.layers{l}.a)
Expand Down
7 changes: 5 additions & 2 deletions CNN/cnnff.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@
elseif strcmp(net.layers{l}.type, 's')
% downsample
for j = 1 : inputmaps
z = convn(net.layers{l - 1}.a{j}, ones(net.layers{l}.scale) / (net.layers{l}.scale ^ 2), 'valid'); % !! replace with variable
net.layers{l}.a{j} = z(1 : net.layers{l}.scale : end, 1 : net.layers{l}.scale : end, :);
xscale = net.layers{l}.xscale;
yscale = net.layers{l}.yscale;

z = convn(net.layers{l - 1}.a{j}, ones(xscale, yscale) / (xscale*yscale), 'valid'); % !! replace with variable
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please calculate ones(xscale, yscale) / (xscale*yscale) in cnnsetup, put it in the net somewhere (net._meanFilter or similar), use that and remove the comment to replace with var

net.layers{l}.a{j} = z(1 : xscale : end, 1 : yscale : end, :);
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion CNN/cnnsetup.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

for l = 1 : numel(net.layers) % layer
if strcmp(net.layers{l}.type, 's')
mapsize = mapsize / net.layers{l}.scale;
mapsize = [mapsize(1)/net.layers{l}.xscale, mapsize(2)/net.layers{l}.yscale];
assert(all(floor(mapsize)==mapsize), ['Layer ' num2str(l) ' size must be integer. Actual: ' num2str(mapsize)]);
for j = 1 : inputmaps
net.layers{l}.b{j} = 0;
Expand Down
4 changes: 2 additions & 2 deletions tests/test_cnn_gradients_are_numerically_correct.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
cnn.layers = {
struct('type', 'i') %input layer
struct('type', 'c', 'outputmaps', 2, 'kernelsize', 5) %convolution layer
struct('type', 's', 'scale', 2) %sub sampling layer
struct('type', 's', 'xscale', 2, 'yscale', 2) %sub sampling layer
struct('type', 'c', 'outputmaps', 2, 'kernelsize', 5) %convolution layer
struct('type', 's', 'scale', 2) %subsampling layer
struct('type', 's', 'xscale', 2, 'yscale', 2) %subsampling layer
};
cnn = cnnsetup(cnn, batch_x, batch_y);

Expand Down
5 changes: 2 additions & 3 deletions tests/test_example_CNN.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
cnn.layers = {
struct('type', 'i') %input layer
struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer
struct('type', 's', 'scale', 2) %sub sampling layer
struct('type', 's', 'xscale', 2, 'yscale', 2) %sub sampling layer
struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer
struct('type', 's', 'scale', 2) %subsampling layer
struct('type', 's', 'xscale', 2, 'yscale', 2) %subsampling layer
};


opts.alpha = 1;
opts.batchsize = 200;
opts.numepochs = 7;
Expand Down