Skip to content

Commit

Permalink
new
Browse files Browse the repository at this point in the history
  • Loading branch information
doxawang committed Jan 11, 2022
1 parent 4f0966a commit 8a48f8f
Show file tree
Hide file tree
Showing 20 changed files with 1,302 additions and 111 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@ python3 ../../../main_linear.py \
--name $1-linear \
--entity doxawang \
--project solo-learn \
$4 \
--wandb
--pretrained_feature_extractor $4 \
--use_poison \
--poison_data $5 \
--load_linear \
# --wandb
109 changes: 101 additions & 8 deletions bash_files/pretrain/cifar/exe.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
rate = '0.60'
dataset = 'cifar10'
# poison_method = 'zoo-simclr'
poison_method = 'clb'
poison_method = 'zoo-simclr'
# poison_method = 'clb'
import time
out_dir = '/data/yfwang/solo-learn-outputs'

def sweep_poison_rate(args):
i = 0
# for dataset in ['cifar10', 'cifar100']:
for dataset in ['cifar100']:
for rate in '0.10 0.20 0.30 0.40 0.50 0.60 0.70 0.80 0.90 1.00'.split(' '):
for dataset in ['cifar10']:
# for rate in '0.10 0.20 0.30 0.40 0.50 0.60 0.70 0.80 0.90 1.00'.split(' '):
for rate in '0.90 1.00 1.10 1.20'.split(' '):
gpu = args.gpus[i]
print(rate)
os.system(f"""
Expand All @@ -36,8 +37,8 @@ def sweep_pretrain_method(args):
os.system(f"""
for file in {out_dir}/poison_datasets/{dataset}/{poison_method}/gaussian_noise/{dataset}_{poison_method}_rate_{rate}_*.pt
do
# echo ${{file}}, {method}
CUDA_VISIBLE_DEVICES={gpu} sh {method}.sh {dataset} " --poison_data ${{file}} --use_poison --checkpoint_dir {out_dir}/pretrain/{dataset} " &
# echo ${{file}}, {method}, {dataset}, {out_dir}
# CUDA_VISIBLE_DEVICES={gpu} sh {method}.sh {dataset} " --poison_data ${{file}} --use_poison --checkpoint_dir {out_dir}/pretrain/{dataset} " &
done
"""
)
Expand Down Expand Up @@ -97,6 +98,93 @@ def sweep_cifar100(args):
return
time.sleep(1)


def sweep_poison_pretrain_method(args):
i = 0
# for dataset in ['cifar10', 'cifar100']:
# for method in 'dino'.split(' '):
for method in ['supcon', 'mocov2plus', 'byol', 'simsiam', 'swav', 'dino', 'barlow']:
poison_method = 'zoo-' + method
# for rate in '0.10 0.20 0.30 0.40 0.50 0.60 0.70 0.80 0.90 1.00'.split(' '):
gpu = args.gpus[i]
print(rate)

os.system(f"""
for file in {out_dir}/poison_datasets/{dataset}/{poison_method}/gaussian_noise/{dataset}_{poison_method}_rate_{rate}_*.pt
do
echo ${{file}}, {method}
# CUDA_VISIBLE_DEVICES={gpu} sh {method}.sh {dataset} " --poison_data ${{file}} --use_poison --checkpoint_dir {out_dir}/pretrain/{dataset} " &
CUDA_VISIBLE_DEVICES={gpu} sh simclr.sh {dataset} " --poison_data ${{file}} --use_poison --checkpoint_dir {out_dir}/pretrain/{dataset} " &
done
"""
)
i += 1
if i >= len(args.gpus):
return
time.sleep(1)

def sweep_alpha(args):
i = 0
for dataset in ['cifar10', 'cifar100']:
# for alpha in '0.05 0.10'.split(' '):
for alpha in '0.15'.split(' '):
gpu = args.gpus[i]
print(rate)
os.system(f"""
for file in /data/yfwang/solo-learn/poison_datasets/{dataset}/zoo-simclr/gaussian_noise/{dataset}_zoo-simclr_rate_{rate}_*_{alpha}*.pt
do
# echo ${{file}}
CUDA_VISIBLE_DEVICES={gpu} sh simclr.sh {dataset} " --poison_data ${{file}} --use_poison --checkpoint_dir /data/yfwang/solo-learn/pretrain/{dataset} " &
done
"""
)
i += 1
if i >= len(args.gpus):
return

def sweep_trigger(args):
i = 0
for dataset in ['cifar10', 'cifar100']:
# for alpha in '0.05 0.10'.split(' '):
# for alpha in '0.15'.split(' '):
for trigger in 'checkerboard_1corner checkerboard_4corner checkerboard_center checkerboard_full gaussian_noise'.split(' '):
gpu = args.gpus[i]
print(rate)
os.system(f"""
for file in {out_dir}/poison_datasets/{dataset}/zoo-simclr/{trigger}/{dataset}_zoo-simclr_rate_{rate}_target_None_trigger_{trigger}_*.pt
do
# rm $file
# echo ${{file}}
CUDA_VISIBLE_DEVICES={gpu} sh simclr.sh {dataset} " --poison_data ${{file}} --use_poison --checkpoint_dir /data/yfwang/solo-learn/pretrain/{dataset} " &
done
"""
)
i += 1
if i >= len(args.gpus):
return

def sweep_trial(args):
i = 0
# for dataset in ['cifar10', 'cifar100']:
# for alpha in '0.05 0.10'.split(' '):
# for alpha in '0.15'.split(' '):
for budget in '5 50'.split(' '):
for trial in '0 1 2 3 4'.split(' '):
gpu = args.gpus[i]
print(rate)
os.system(f"""
for file in {out_dir}/poison_datasets/{dataset}/{poison_method}/gaussian_noise/budget_{budget}/{dataset}_{poison_method}_rate_{rate}_target_0_trigger_gaussian_noise_alpha_0.20_class_0_trial_{trial}_*.pt
do
# rm $file
# echo ${{file}}
CUDA_VISIBLE_DEVICES={gpu} sh simclr.sh {dataset} " --poison_data ${{file}} --use_poison --checkpoint_dir /data/yfwang/solo-learn/pretrain/{dataset} " &
done
"""
)
i += 1
if i >= len(args.gpus):
return

if __name__ == "__main__":
import argparse
import os
Expand All @@ -108,5 +196,10 @@ def sweep_cifar100(args):
args = parser.parse_args()
# sweep_pretrain_method(args)
# sweep_pretrain_method(args)
# sweep_eval(args)/
sweep_cifar100(args)
# sweep_eval(args)
# sweep_cifar100(args)
# sweep_poison_pretrain_method(args)
# sweep_alpha(args)
# sweep_poison_rate(args)
# sweep_trigger(args)
sweep_trial(args)
Binary file added figs/clean_1000_t-SNE.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figs/clean_t-SNE_90_13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figs/poison_1000_t-SNE.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figs/poison_t-SNE_24_21.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figs/raw_t-SNE.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed figs/simclr_t-SNE.png
Binary file not shown.
Binary file added figs/trigger.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 8a48f8f

Please sign in to comment.