Skip to content

Commit

Permalink
Merge pull request #243 from mldiego/master
Browse files Browse the repository at this point in the history
Some experimenting with GPU, fix few issues
  • Loading branch information
mldiego authored Sep 25, 2024
2 parents 2b13d82 + 5ae592c commit c04352a
Show file tree
Hide file tree
Showing 366 changed files with 613 additions and 38 deletions.
11 changes: 2 additions & 9 deletions code/nnv/engine/nn/layers/FullyConnectedLayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -284,15 +284,8 @@

n = in_image.numPred;
V(1, 1, :, in_image.numPred + 1) = zeros(obj.OutputSize, 1, 'like', in_image.V);
for i=1:n+1
I = in_image.V(:,:,:,i);
I = reshape(I,N,1); % flatten input
if i==1
V(1, 1,:,i) = obj.Weights*I + obj.Bias;
else
V(1, 1,:,i) = obj.Weights*I;
end
end
V(1, 1, :, :) = obj.Weights*reshape(in_image.V, N, n + 1);
V(1, 1, :, 1) = reshape(V(1, 1, :, 1), obj.OutputSize, 1) + obj.Bias;
% output set
image = ImageStar(V, in_image.C, in_image.d, in_image.pred_lb, in_image.pred_ub);
else % reach Star set
Expand Down
6 changes: 6 additions & 0 deletions code/nnv/engine/nn/layers/ImageInputLayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@
image = in_image;
elseif strcmp(obj.Normalization, 'zerocenter')
image = in_image.affineMap([], -obj.Mean);
elseif strcmp(obj.Normalization, 'zscore')
image = in_image.affineMap([], -obj.Mean);
layer_std = obj.StandardDeviation;
for nc = 1:image.numChannel
image.V(:,:,nc,:) = image.V(:,:,nc,:)/layer_std(nc);
end
else
error('The normalization method is not supported yet.')
end
Expand Down
2 changes: 1 addition & 1 deletion code/nnv/engine/set/Box.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
% Speeding up implementation
gens = diag(vec); % generate matrix
if numel(gens) > 1
gens(:,all(gens(gens==0))) = []; % delete colums with no info
gens(:,all(gens==0)) = []; % delete colums with no info
end
obj.generators = gens;
catch
Expand Down
8 changes: 4 additions & 4 deletions code/nnv/engine/set/VolumeStar.m
Original file line number Diff line number Diff line change
Expand Up @@ -554,16 +554,16 @@
S.V = gather(S.V);
S.C = gather(S.C);
S.d = gather(S.d);
S.predicate_lb = gather(S.predicate_lb);
S.predicate_ub = gather(S.predicate_ub);
S.pred_lb = gather(S.pred_lb);
S.pred_ub = gather(S.pred_ub);
S.vol_lb = gather(S.vol_lb);
S.vol_ub = gather(S.vol_ub);
elseif strcmp(deviceTarget, 'gpu')
S.V = gpuArray(S.V);
S.C = gpuArray(S.C);
S.d = gpuArray(S.d);
S.predicate_lb = gpuArray(S.predicate_lb);
S.predicate_ub = gpuArray(S.predicate_ub);
S.pred_lb = gpuArray(S.pred_lb);
S.pred_ub = gpuArray(S.pred_ub);
S.vol_lb = gpuArray(S.vol_lb);
S.vol_ub = gpuArray(S.vol_ub);
else
Expand Down
4 changes: 2 additions & 2 deletions code/nnv/engine/utils/lpsolver.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
% Define solver parameters
params = struct; % for now, leave default options/params
params.OutputFlag = 0; % no display
params.OptimalityTol = 1e-09;
params.FeasibilityTol = 1e-09;
% params.OptimalityTol = 1e-09;
% params.FeasibilityTol = 1e-09;
result = gurobi(model, params);
fval = result.objval; % get fval value from results
% get exitflag and match those of linprog for easier parsing
Expand Down
4 changes: 4 additions & 0 deletions code/nnv/engine/utils/verify_specification.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
if ~isa(Set, "Star")
Set = Set.toStar;
end
if isa(Set.V, 'gpuArray')
Set = Set.changeDevice('cpu');
end
S = Set.intersectHalfSpace(property.G, property.g); % compute intersection with unsafe/not robust region
if isempty(S)
result = 1; % no intersection with unsafe region = safe (unsat)
Expand All @@ -57,6 +60,7 @@
continue; % does nothing, just need an statement, wanted to make this clear
else
result = 2; % unknown if approx, sat if exact
return;
end
end
cp = cp+1;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified code/nnv/examples/Submission/WiP_3d/plots/nodule/avgTime_dark_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified code/nnv/examples/Submission/WiP_3d/plots/organ/avgTime_dark_5.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit c04352a

Please sign in to comment.