Skip to content

Commit

Permalink
change param name according to paper
Browse files Browse the repository at this point in the history
  • Loading branch information
snoop2head committed Jul 11, 2022
1 parent 716c3d7 commit 9db15a8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# config for shadow
CFG:
DEBUG: false
num_accessible_probs: 10 # match with accessible classes logits/probability classes number from the target model. usually top 5 for APIs
topk_num_accessible_probs: 10 # topk match with accessible classes logits/probability classes number from the target model. usually top 5 for APIs
num_epochs: 25 # number of shadow model train epochs
val_acc_goal: -1 # shadow model's goal accuracy working as early stop. -1 for not using early stop
num_shadow_models: 100
Expand Down
4 changes: 2 additions & 2 deletions shadow/make_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def make_member_nonmember(finetuned_model, trainloader, valloader, criterion, de
prob = F.softmax(output, dim=1) # softmax logits

# get top inferred classes probability and append to member_dset
top_p, top_class = prob.topk(CFG.num_accessible_probs, dim=1)
top_p, top_class = prob.topk(CFG.topk_num_accessible_probs, dim=1)
top_p = top_p.cpu().detach().numpy() # detach from cuda
# loss = criterion(output, labels)
member_dset.append(top_p)
Expand All @@ -53,7 +53,7 @@ def make_member_nonmember(finetuned_model, trainloader, valloader, criterion, de
prob = F.softmax(output, dim=1) # softmax logits

# get top inferred classes probability and append to member_dset
top_p, top_class = prob.topk(CFG.num_accessible_probs, dim=1)
top_p, top_class = prob.topk(CFG.topk_num_accessible_probs, dim=1)
top_p = top_p.cpu().detach().numpy() # detach from cuda

# append to non_member_dset
Expand Down
2 changes: 1 addition & 1 deletion train_shadow.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

# define dataset for attack model that shadow models will generate
print("mapped classes to ids:", trainset.class_to_idx)
columns_attack_sdet = [f"top_{index}_prob" for index in range(CFG.num_accessible_probs)]
columns_attack_sdet = [f"top_{index}_prob" for index in range(CFG.topk_num_accessible_probs)]
df_attack_dset = pd.DataFrame({}, columns=columns_attack_sdet + ["is_member"])

# random subset for shadow model train & validation from the CIFAR trainset
Expand Down

0 comments on commit 9db15a8

Please sign in to comment.