Skip to content

Commit

Permalink
DeepPoly ReLU and FullyConnected
Browse files Browse the repository at this point in the history
  • Loading branch information
MekAkUActOR committed Nov 22, 2022
1 parent fd5f98d commit 9caea2d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
3 changes: 2 additions & 1 deletion code/deeppoly.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ def __init__(self, in_features):
super(DPReLU, self).__init__()
self.in_features = in_features
self.out_features = in_features
self.alpha = torch.nn.Parameter(torch.ones(in_features))
# self.alpha = torch.nn.Parameter(torch.ones(in_features))
self.alpha = torch.nn.Parameter(torch.rand(in_features) * 0.7854)
self.alpha.requires_grad = True

def forward(self, x):
Expand Down
7 changes: 1 addition & 6 deletions code/verifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,9 @@ def analyze(net, inputs, eps, true_label):
up_bound = nomalize((inputs + eps).clamp(0, 1), inputs)

####################################### new added
for alpha in range(1, 8):
alpha = alpha / 10
for alpha in range(10):
verifiable_net = verifiable(net, inputs)
optimizer = optim.Adam(verifiable_net.parameters(), lr=LR)
for p in verifiable_net.parameters():
if p.requires_grad:
p.data.clamp_(alpha, alpha)

for i in range(num_iter):
optimizer.zero_grad()
verifier_output = verifiable_net(DeepPoly(low_bound.shape[0], low_bound, up_bound))
Expand Down

0 comments on commit 9caea2d

Please sign in to comment.