Skip to content

Commit

Permalink
Merge pull request #12 from trhoangdung/master
Browse files Browse the repository at this point in the history
fix minor error LinearNNCS
  • Loading branch information
mldiego authored Aug 20, 2020
2 parents 721fc7a + 6963b40 commit ebcbc75
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 31 deletions.
4 changes: 1 addition & 3 deletions code/nnv/engine/nn/cnn/CNN.m
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,7 @@ function start_pool(obj)
error('Invalid number of input arguments, the number should be 1, 2, 3, 4, 5, or 6');

end




if obj.numCores > 1
obj.start_pool;
obj.reachOption = 'parallel';
Expand Down
33 changes: 11 additions & 22 deletions code/nnv/engine/nn/funcs/LogSig.m
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@
if ~isa(I, 'Star')
error('Input is not a star');
end
if relaxFactor < 0 || relaxFactor > 1
if (relaxFactor < 0) || (relaxFactor > 1)
error('Invalid relax factor');
end

Expand Down Expand Up @@ -1302,56 +1302,45 @@
% 7/16/2020: add lp_solver option

switch nargin
case 6
I = varargin{1};
method = varargin{2};
option = varargin{3};
relaxFactor = varargin{4}; % used for aprox-star only
dis_opt = varargin{5}; % display option
lp_solver = varargin{6}; % lp solver option
case 5
I = varargin{1};
method = varargin{2};
option = varargin{3};
relaxFactor = varargin{4}; % used for aprox-star only
dis_opt = varargin{5}; % display option
lp_solver = 'linprog';
relaxFactor = varargin{3}; % used for aprox-star only
dis_opt = varargin{4}; % display option
lp_solver = varargin{5}; % lp solver option
case 4
I = varargin{1};
method = varargin{2};
option = varargin{3};
relaxFactor = varargin{4}; % for relaxed approx-star method
dis_opt = [];
relaxFactor = varargin{3}; % used for aprox-star only
dis_opt = varargin{4}; % display option
lp_solver = 'linprog';

case 3
I = varargin{1};
method = varargin{2};
option = varargin{3};
relaxFactor = 0; % for relaxed approx-star method
relaxFactor = varargin{3}; % for relaxed approx-star method
dis_opt = [];
lp_solver = 'linprog';

case 2
I = varargin{1};
method = varargin{2};
option = [];
relaxFactor = 0; % for relaxed approx-star method
dis_opt = [];
lp_solver = 'linprog';

case 1
I = varargin{1};
method = 'approx-star';
option = [];
relaxFactor = 0; % for relaxed approx-star method
dis_opt = [];
lp_solver = 'linprog';
otherwise
error('Invalid number of input arguments (should be 1, 2, 3, 4, 5, or 6)');
error('Invalid number of input arguments (should be 1, 2, 3, 4, or 5)');
end


if strcmp(method, 'approx-star') || strcmp(method, 'approx-star-no-split') || strcmp(method, 'approx-star-split')

R = LogSig.reach_star_approx(I, method, relaxFactor, dis_opt, lp_solver);

elseif strcmp(method, 'approx-zono') % over-approximate analysis using zonotope
Expand Down
5 changes: 2 additions & 3 deletions code/nnv/engine/nn/layers/SigmoidLayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@
error('input is not an ImageStar');
end


h = in_image.height;
w = in_image.width;
c = in_image.numChannel;
Expand Down Expand Up @@ -136,7 +135,7 @@

images = [];
n = length(in_images);

if strcmp(option, 'parallel')
parfor i=1:n
images = [images obj.reach_star_single_input(in_images(i), method, relaxFactor, dis_opt, lp_solver)];
Expand Down Expand Up @@ -260,7 +259,7 @@
otherwise
error('Invalid number of input arguments (should be 2,3,4,5 or 6)');
end

if strcmp(method, 'approx-star') || strcmp(method, 'abs-dom')
images = obj.reach_star_multipleInputs(in_images, method, option, relaxFactor, dis_opt, lp_solver);
elseif strcmp(method, 'approx-zono')
Expand Down
6 changes: 3 additions & 3 deletions code/nnv/engine/nncs/LinearODE.m
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@
for j=1:m
V = [V Z{1, j}(:, i)];
end
R = [R Star(V, X0.C, X0.d)]; % reachable set
R = [R Star(V, X0.C, X0.d, X0.predicate_lb, X0.predicate_ub)]; % reachable set
end

end
Expand Down Expand Up @@ -543,7 +543,7 @@
for j=1:k
V = [V Z{1, j}(:, i)];
end
R = [R Star(V, X0.C, X0.d)]; % reachable set
R = [R Star(V, X0.C, X0.d, X0.predicate_lb, X0.predicate_ub)]; % reachable set
end

end
Expand Down Expand Up @@ -577,7 +577,7 @@
for j=1:m
V = [V Z{1, j}(:, i)];
end
R = [R Star(V, X0.C, X0.d)]; % reachable set
R = [R Star(V, X0.C, X0.d, X0.predicate_lb, X0.predicate_ub)]; % reachable set
end

end
Expand Down

0 comments on commit ebcbc75

Please sign in to comment.