Skip to content

Commit

Permalink
Run experiments with correctly classified inputs only
Browse files Browse the repository at this point in the history
  • Loading branch information
mldiego committed Aug 28, 2024
1 parent 13a2fc0 commit 3eda77b
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 23 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
22 changes: 18 additions & 4 deletions code/nnv/examples/Submission/WiP_3d/verify_adrenal.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down
22 changes: 18 additions & 4 deletions code/nnv/examples/Submission/WiP_3d/verify_fracture.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
22 changes: 18 additions & 4 deletions code/nnv/examples/Submission/WiP_3d/verify_nodule.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
20 changes: 17 additions & 3 deletions code/nnv/examples/Submission/WiP_3d/verify_organ.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
22 changes: 18 additions & 4 deletions code/nnv/examples/Submission/WiP_3d/verify_synapse.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
22 changes: 18 additions & 4 deletions code/nnv/examples/Submission/WiP_3d/verify_vessel.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3eda77b

Please sign in to comment.