diff --git a/code/nnv/engine/set/ImageStar.m b/code/nnv/engine/set/ImageStar.m index ec05645ec..3c704f435 100644 --- a/code/nnv/engine/set/ImageStar.m +++ b/code/nnv/engine/set/ImageStar.m @@ -857,10 +857,13 @@ if isempty(obj.im_lb) || isempty(obj.im_ub) - x1 = obj.V(:,:,:,1) + tensorprod(obj.V(:,:,:,2:end), obj.pred_lb, 4, 1); - x2 = obj.V(:,:,:,1) + tensorprod(obj.V(:,:,:,2:end), obj.pred_ub, 4, 1); - image_lb = min(x1,x2); - image_ub = max(x1,x2); + gens = obj.V(:,:,:,2:end); + pos_gens = gens; + pos_gens(gens < 0) = 0; + neg_gens = gens; + neg_gens(gens > 0) = 0; + image_lb = obj.V(:,:,:,1) + tensorprod(pos_gens, obj.pred_lb, 4, 1) + tensorprod(neg_gens, obj.pred_ub, 4, 1); + image_ub = obj.V(:,:,:,1) + tensorprod(pos_gens, obj.pred_ub, 4, 1) + tensorprod(neg_gens, obj.pred_lb, 4, 1); obj.im_lb = image_lb; obj.im_ub = image_ub; diff --git a/code/nnv/examples/Submission/WiP_3d/results/verification_adrenal_add_1_100.mat b/code/nnv/examples/Submission/WiP_3d/results/verification_adrenal_add_1_100.mat index 2459cf1eb..46467e7d8 100644 Binary files a/code/nnv/examples/Submission/WiP_3d/results/verification_adrenal_add_1_100.mat and b/code/nnv/examples/Submission/WiP_3d/results/verification_adrenal_add_1_100.mat differ diff --git a/code/nnv/examples/Submission/WiP_3d/results/verification_adrenal_add_1_50.mat b/code/nnv/examples/Submission/WiP_3d/results/verification_adrenal_add_1_50.mat index cefb924db..ba7665259 100644 Binary files a/code/nnv/examples/Submission/WiP_3d/results/verification_adrenal_add_1_50.mat and b/code/nnv/examples/Submission/WiP_3d/results/verification_adrenal_add_1_50.mat differ diff --git a/code/nnv/examples/Submission/WiP_3d/results/verification_adrenal_add_1_500.mat b/code/nnv/examples/Submission/WiP_3d/results/verification_adrenal_add_1_500.mat index b5f320463..6725614fe 100644 Binary files a/code/nnv/examples/Submission/WiP_3d/results/verification_adrenal_add_1_500.mat and b/code/nnv/examples/Submission/WiP_3d/results/verification_adrenal_add_1_500.mat differ diff --git a/code/nnv/examples/Submission/WiP_3d/verify_adrenal.m b/code/nnv/examples/Submission/WiP_3d/verify_adrenal.m index de5e9f0fd..080897466 100644 --- a/code/nnv/examples/Submission/WiP_3d/verify_adrenal.m +++ b/code/nnv/examples/Submission/WiP_3d/verify_adrenal.m @@ -11,7 +11,7 @@ load(dataset); % data to verify (test set) -test_images = permute(test_images, [2 3 4 5 1]); +test_images = squeeze(permute(test_images, [2 3 4 5 1])); test_labels = test_labels + 1; % load network @@ -21,8 +21,22 @@ % select volumes to verify N = 50; -inputs = single(test_images(:,:,:,:,1:N)); -targets = single(test_labels(1:N)); +idxs = zeros(N,1); +count = 1; + +for i = 1:length(test_labels) + y = classify(matlabNet,test_images(:,:,:,i)); + if single(y) == test_labels(i) + idxs(count) = i; + count = count + 1; + end + if count > N + break + end +end + +inputs = single(test_images(:,:,:,idxs)); +targets = single(test_labels(idxs)); % Reachability parameters reachOptions = struct; @@ -54,7 +68,7 @@ % 3) Begin verification analysis for i=1:N - img = squeeze(inputs(:,:,:,:,i)); + img = inputs(:,:,:,i); target = targets(i); results(i,:) = verify_instance_shape(net, img, target, adv_attack, reachOptions); end diff --git a/code/nnv/examples/Submission/WiP_3d/verify_fracture.m b/code/nnv/examples/Submission/WiP_3d/verify_fracture.m index d62961501..a4f3c119d 100644 --- a/code/nnv/examples/Submission/WiP_3d/verify_fracture.m +++ b/code/nnv/examples/Submission/WiP_3d/verify_fracture.m @@ -20,9 +20,23 @@ net = matlab2nnv(net); % select volumes to verify -N = 50; % even for numCores -inputs = single(test_images(:,:,:,:,1:N)); -targets = single(test_labels(1:N)); +N = 50; +idxs = zeros(N,1); +count = 1; + +for i = 1:length(test_labels) + y = classify(matlabNet,test_images(:,:,:,i)); + if single(y) == test_labels(i) + idxs(count) = i; + count = count + 1; + end + if count > N + break + end +end + +inputs = single(test_images(:,:,:,idxs)); +targets = single(test_labels(idxs)); % Reachability parameters reachOptions = struct; @@ -57,7 +71,7 @@ % 3) Begin verification analysis for i=1:N - img = squeeze(inputs(:,:,:,:,i)); + img = inputs(:,:,:,i); target = targets(i); results(i,:) = verify_instance_3d(net, img, target, adv_attack, reachOptions); end diff --git a/code/nnv/examples/Submission/WiP_3d/verify_nodule.m b/code/nnv/examples/Submission/WiP_3d/verify_nodule.m index 0e6e7f6af..5c48d4926 100644 --- a/code/nnv/examples/Submission/WiP_3d/verify_nodule.m +++ b/code/nnv/examples/Submission/WiP_3d/verify_nodule.m @@ -20,9 +20,23 @@ net = matlab2nnv(net); % select volumes to verify -N = 50; % even for numCores -inputs = single(test_images(:,:,:,:,1:N)); -targets = single(test_labels(1:N)); +N = 50; +idxs = zeros(N,1); +count = 1; + +for i = 1:length(test_labels) + y = classify(matlabNet,test_images(:,:,:,i)); + if single(y) == test_labels(i) + idxs(count) = i; + count = count + 1; + end + if count > N + break + end +end + +inputs = single(test_images(:,:,:,idxs)); +targets = single(test_labels(idxs)); % Reachability parameters reachOptions = struct; @@ -58,7 +72,7 @@ % 3) Begin verification analysis for i=1:N - img = squeeze(inputs(:,:,:,:,i)); + img = inputs(:,:,:,i); target = targets(i); results(i,:) = verify_instance_3d(net, img, target, adv_attack, reachOptions); end diff --git a/code/nnv/examples/Submission/WiP_3d/verify_organ.m b/code/nnv/examples/Submission/WiP_3d/verify_organ.m index 563f5ca2c..4245ecc1e 100644 --- a/code/nnv/examples/Submission/WiP_3d/verify_organ.m +++ b/code/nnv/examples/Submission/WiP_3d/verify_organ.m @@ -21,8 +21,22 @@ % select volumes to verify N = 50; -inputs = single(test_images(:,:,:,:,1:N)); -targets = single(test_labels(1:N)); +idxs = zeros(N,1); +count = 1; + +for i = 1:length(test_labels) + y = classify(matlabNet,test_images(:,:,:,i)); + if single(y) == test_labels(i) + idxs(count) = i; + count = count + 1; + end + if count > N + break + end +end + +inputs = single(test_images(:,:,:,idxs)); +targets = single(test_labels(idxs)); % Reachability parameters reachOptions = struct; @@ -57,7 +71,7 @@ % 3) Begin verification analysis for i=1:N - img = squeeze(inputs(:,:,:,:,i)); + img = inputs(:,:,:,i); target = targets(i); results(i,:) = verify_instance_3d(net, img, target, adv_attack, reachOptions); end diff --git a/code/nnv/examples/Submission/WiP_3d/verify_synapse.m b/code/nnv/examples/Submission/WiP_3d/verify_synapse.m index e09474ffb..b4e346f5b 100644 --- a/code/nnv/examples/Submission/WiP_3d/verify_synapse.m +++ b/code/nnv/examples/Submission/WiP_3d/verify_synapse.m @@ -20,9 +20,23 @@ net = matlab2nnv(net); % select volumes to verify -N = 50; % even for numCores -inputs = single(test_images(:,:,:,:,1:N)); -targets = single(test_labels(1:N)); +N = 50; +idxs = zeros(N,1); +count = 1; + +for i = 1:length(test_labels) + y = classify(matlabNet,test_images(:,:,:,i)); + if single(y) == test_labels(i) + idxs(count) = i; + count = count + 1; + end + if count > N + break + end +end + +inputs = single(test_images(:,:,:,idxs)); +targets = single(test_labels(idxs)); % Reachability parameters reachOptions = struct; @@ -57,7 +71,7 @@ % 3) Begin verification analysis for i=1:N - img = squeeze(inputs(:,:,:,:,i)); + img = inputs(:,:,:,i); target = targets(i); results(i,:) = verify_instance_3d(net, img, target, adv_attack, reachOptions); end diff --git a/code/nnv/examples/Submission/WiP_3d/verify_vessel.m b/code/nnv/examples/Submission/WiP_3d/verify_vessel.m index 738fa2cf4..ac203f647 100644 --- a/code/nnv/examples/Submission/WiP_3d/verify_vessel.m +++ b/code/nnv/examples/Submission/WiP_3d/verify_vessel.m @@ -20,9 +20,23 @@ net = matlab2nnv(net); % select volumes to verify -N = 50; % even for numCores -inputs = single(test_images(:,:,:,:,1:N)); -targets = single(test_labels(1:N)); +N = 50; +idxs = zeros(N,1); +count = 1; + +for i = 1:length(test_labels) + y = classify(matlabNet,test_images(:,:,:,i)); + if single(y) == test_labels(i) + idxs(count) = i; + count = count + 1; + end + if count > N + break + end +end + +inputs = single(test_images(:,:,:,idxs)); +targets = single(test_labels(idxs)); % Reachability parameters reachOptions = struct; @@ -52,7 +66,7 @@ % 3) Begin verification analysis for i=1:N - img = squeeze(inputs(:,:,:,:,i)); + img = inputs(:,:,:,i); target = targets(i); results(i,:) = verify_instance_shape(net, img, target, adv_attack, reachOptions); end