# python pretrained_mgd.py \
#   -a vit_base \
#   --dist-url 'tcp://localhost:10001' \
#   --multiprocessing-distributed --world-size 8 --rank 0 \
#   --pretrained '/data/cuipeng/vit-b-300ep.pth.tar'

# python pretrained_mgd.py \
#   -a vit_base \
#   --pretrained '/data/cuipeng/vit-b-300ep.pth.tar'

# t-SNE
# resnet 50
# python feature_vis_moco.py \
#     --data-set CIFAR10\
#   --dist-url 'tcp://localhost:30001' \
#   --multiprocessing-distributed --world-size 1 --rank 0 \
#   --pretrained '/data/cuipeng/r-50-1000ep.pth.tar' \

# vit-base-moco
# python feature_vis_moco.py \
#   -a vit_base --lr=3 \
#   --dist-url 'tcp://localhost:10001' \
#   --multiprocessing-distributed --world-size 1 --rank 0 \
#   --pretrained '/data/cuipeng/vit-b-300ep.pth.tar' 

# vis_21k
# python feature_vis_moco.py \
#   -a base_21k --lr=3 \
#   --dist-url 'tcp://localhost:10001' \
#   --multiprocessing-distributed --world-size 1 --rank 0 \

# export CUDA_VISIBLE_DEVICES=6
# # train ranking models
# python train_ensemble.py --save_model --num_epochs 180 --milestones 80 120 150 --lr 0.10 --gamma 0.2 --ensemble_num 1 --dataset cifar10

# python train_ensemble.py --save_model --num_epochs 180 --milestones 80 120 150 --lr 0.10 --gamma 0.2 --ensemble_num 1 --dataset cifar100

# # vit pretrained model

# python train_ensemble.py --save_model --num_epochs 180 --milestones 80 120 150 --lr 0.10 --gamma 0.2 --ensemble_num 1 --dataset cifar10 --net_type wide_resnet --maha_file ./ssl/maha_dict_vit_c10.npy

# python train_ensemble.py --save_model --num_epochs 180 --milestones 80 120 150 --lr 0.10 --gamma 0.2 --ensemble_num 1 --dataset cifar100 --net_type wide_resnet --maha_file ./ssl/maha_dict_vit_c100.npy

# python train_ensemble.py --save_model --num_epochs 180 --milestones 80 120 150 --lr 0.10 --gamma 0.2 --ensemble_num 1 --dataset cifar100 --maha_file ./ssl/maha_dict_vit_c100.npy 

# python train_ensemble.py --save_model --num_epochs 180 --milestones 80 120 150 --lr 0.10 --gamma 0.2 --ensemble_num 1 --dataset cifar100 --net_type wide_resnet --maha_file ./ssl/maha_dict_vit_c100.npy

# # vit21k pretrained model
# python train_ensemble.py --save_model --num_epochs 180 --milestones 80 120 150 --lr 0.10 --gamma 0.2 --ensemble_num 1 --dataset cifar10 --maha_file ./ssl/maha_dict_vit21k_c10.npy 

# python train_ensemble.py --save_model --num_epochs 180 --milestones 80 120 150 --lr 0.10 --gamma 0.2 --ensemble_num 1 --dataset cifar10 --net_type wide_resnet --maha_file ./ssl/maha_dict_vit21k_c10.npy

# python train_ensemble.py --save_model --num_epochs 180 --milestones 80 120 150 --lr 0.10 --gamma 0.2 --ensemble_num 1 --dataset cifar100 --maha_file ./ssl/maha_dict_vit21k_c100.npy 

# python train_ensemble.py --save_model --num_epochs 180 --milestones 80 120 150 --lr 0.10 --gamma 0.2 --ensemble_num 1 --dataset cifar100 --net_type wide_resnet --maha_file ./ssl/maha_dict_vit21k_c100.npy

# CUDA_VISIBLE_DEVICES=0,1,2 nohup python train_ensemble.py --save_model --num_epochs 180 --milestones 80 120 150 --lr 0.10 --gamma 0.2 --ensemble_num 1 --dataset cifar10 -a vit_base --pretrained '/data/cuipeng/vit-b-300ep.pth.tar' --maha_file ./ssl/maha_dict_vit_c10_768.npy >resnet34_c10_vit_768.log 2>&1 &

# CUDA_VISIBLE_DEVICES=3,4,5 nohup python train_ensemble.py --save_model --num_epochs 180 --milestones 80 120 150 --lr 0.10 --gamma 0.2 --ensemble_num 1 --dataset cifar100 -a vit_base --pretrained '/data/cuipeng/vit-b-300ep.pth.tar' --maha_file ./ssl/maha_dict_vit_c100_768.npy >resnet34_c100_vit_768.log 2>&1 &

# CUDA_VISIBLE_DEVICES=2 nohup python train_ensemble.py --save_model --num_epochs 180 --milestones 50 90 120 --lr 0.10 --gamma 0.2 --ensemble_num 1 --dataset cifar10 -a vit_base --pretrained '/data/cuipeng/vit-b-300ep.pth.tar' --maha_file ./ssl/maha_dict_vit_c10_768.npy >resnet34_c10_vit_768.log 2>&1 &

# CUDA_VISIBLE_DEVICES=3 nohup python train_ensemble.py --save_model --num_epochs 180 --milestones 50 90 120 --lr 0.10 --gamma 0.2 --ensemble_num 1 --dataset cifar100 -a vit_base --pretrained '/data/cuipeng/vit-b-300ep.pth.tar' --maha_file ./ssl/maha_dict_vit_c100_768.npy >resnet34_c100_vit_768.log 2>&1 &

# CUDA_VISIBLE_DEVICES=5,6,7 nohup python train_ensemble.py --save_model --num_epochs 180 --milestones 50 90 120 --lr 0.10 --gamma 0.2 --ensemble_num 1 --dataset cifar10 -a base_21k --maha_file ./ssl/maha_dict_vit21k_c10_768.npy >resnet34_c10_vit21k_768.log 2>&1 &

# CUDA_VISIBLE_DEVICES=4,5 nohup python train_ensemble.py --save_model --num_epochs 180 --milestones 50 90 120 --lr 0.10 --gamma 0.2 --ensemble_num 1 --dataset cifar100 -a base_21k --maha_file ./ssl/maha_dict_vit21k_c100_768.npy >resnet34_c100_vit21k_768_maha_new.log 2>&1 &

# CUDA_VISIBLE_DEVICES=6,7 nohup python train_ensemble.py --save_model --num_epochs 180 --milestones 50 90 120 --lr 0.10 --gamma 0.2 --ensemble_num 1 --dataset cifar100 -a base_21k --net_type wide_resnet --maha_file ./ssl/maha_dict_vit21k_c100_768.npy >wresnet28x10_c100_vit21k_768_m.log 2>&1 &

# CUDA_VISIBLE_DEVICES=0,1,2,3 nohup python train_ensemble.py --save_model --num_epochs 180 --milestones 50 90 120 --lr 0.10 --gamma 0.2 --ensemble_num 1 --dataset cifar100 -a vit_base --pretrained '/data/cuipeng/vit-b-300ep.pth.tar' --maha_file ./ssl/maha_dict_vit_c100_768.npy >wresnet28x10_c100_vit_768_m.log 2>&1 &

# python train_ensemble.py --dataset imagenet -a vit_base --pretrained '/data/cuipeng/vit-b-300ep.pth.tar' --maha_file ./ssl/maha_dict_vit_imagenet_768.npy --num_classes 10

# python vis_topk.py --dataset cifar10 -a vit_base --pretrained '/data/cuipeng/vit-b-300ep.pth.tar' --maha_file ./ssl/maha_dict_vit_c10_768.npy --num_classes 10 --model_path ./checkpoint/deep_ens1/resnet34_deep_ens1_cifar10.pkl --args_path ./checkpoint/deep_ens1/resnet34_deep_ens1_cifar10_args.pkl

# python vis_topk.py --dataset cifar10 -a base_21k_fine_tune --maha_file ./ssl/maha_dict_vit21kf_c10_768.npy --num_classes 10 --model_path ./checkpoint/deep_ens1/resnet34_deep_ens1_cifar10.pkl --args_path ./checkpoint/deep_ens1/resnet34_deep_ens1_cifar10_args.pkl

python vis_topk.py --dataset cifar100 -a beit_21k_fine_tune --maha_file ./ssl/maha_dict_beit21kf_c100_768.npy --num_classes 100 --model_path ./checkpoint/deep_ens1/resnet34_deep_ens1_cifar100.pkl --args_path ./checkpoint/deep_ens1/resnet34_deep_ens1_cifar100_args.pkl

python vis_topk_kde.py --dataset cifar100 -a base_21k --num_classes 100 --model_path ./checkpoint/deep_ens1/resnet34_deep_ens1_cifar100.pkl --args_path ./checkpoint/deep_ens1/resnet34_deep_ens1_cifar100_args.pkl
# generate GMM example
python generate_mahalanobis.py --dataset cifar10 -a base_21k --batch_size 256

python test_ood.py --in_dataset cifar100 --ood_dataset cifar10 --model_path ./checkpoint/deep_ens/resnet34_deep_ens1_cifar100_base_21k_rank0.pkl --model_args_path ./checkpoint/deep_ens/resnet34_deep_ens1_cifar100_base_21k_rank0_args.pkl

CUDA_VISIBLE_DEVICES=6,7 nohup python train_ensemble.py --batch_size 256 --save_model --num_epochs 180 --milestones 50 90 120 --lr 0.10 --gamma 0.2 --ensemble_num 1 --dataset cifar100 -a base_21k --maha_file ./ssl/maha_dict_vit21k_c100_768.npy --loss_type margin_max_logits >resnet34_c100_vit21k_768_maha_max_logits.log 2>&1 &

CUDA_VISIBLE_DEVICES=1,2,3,4,5,6,7 python vis_topk.py --dataset cifar100 -a clip16 --maha_file ./ssl/maha_dict_clip16_c100_512.npy --num_classes 100 --model_path ./checkpoint/deep_ens1/resnet34_deep_ens1_cifar100.pkl --args_path ./checkpoint/deep_ens1/resnet34_deep_ens1_cifar100_args.pkl

python test_mis.py --dataset cifar100 -a clip32 --maha_file ./ssl/maha_dict_clip32_c100_512.npy --num_classes 100 --model_path ./checkpoint/deep_ens1/resnet34_deep_ens1_cifar100.pkl --args_path ./checkpoint/deep_ens1/resnet34_deep_ens1_cifar100_args.pkl --batch_size 256 

CUDA_VISIBLE_DEVICES=2,3 nohup python train_ensemble.py --save_model --num_epochs 120 --milestones 30 60 90 --lr 0.30 --gamma 0.1 --ensemble_num 1 --dataset imagenet -a base_21k --loss_type margin_rank --maha_file ./ssl/maha_dict_vit21k_imagenet_768.npy  --batch_size 768 --num_classes 1000 >resnet34_imagenet_vit21k_768_rmaha_rank_margin.log 2>&1 &

CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 nohup python -m torch.distributed.launch --master_port 7666 --nproc_per_node=8 train_ensemble_imagenet_maha.py --batch-size 1024 --lr 0.4 --num_classes 1000 --epochs 120 -a base_21k --loss_type margin_rank_maha --maha_file ./ssl/maha_dict_vit21k_imagenet_768.npy> resnet34_imagenet_vit21k_768_maha_rank_margin.log 2>&1 &

nohup python train_gambler_maha.py  --save_model --num_epochs 250 --milestones 60 120 150 --lr 0.10 --gamma 0.2 --ensemble_num 1 --dataset cifar100 -a clip32 --maha_file ./ssl/maha_dict_clip32_c100_512.npy --loss_type gambler1 --pretrain 70 > maha_gambler_resnet34_c100_clip32_1.log 2>&1 &

nohup python train_gambler_maha.py  --save_model --num_epochs 250 --milestones 60 120 150 --lr 0.10 --gamma 0.2 --ensemble_num 1 --dataset cifar100 -a clip32 --maha_file ./ssl/maha_dict_clip32_c100_512.npy --loss_type gambler2_5 --pretrain 70 --left 2. --right 5. > maha_gambler_resnet34_c100_clip32_2-5.log 2>&1 &

CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 nohup python -m torch.distributed.launch --master_port 7666 --nproc_per_node=8 train_ensemble_imagenet_maha.py --batch-size 512 --lr 0.2 --num_classes 1000 --epochs 120 -a clip32 --maha_file ./ssl/maha_dict_clip32_imagenet_512.npy --loss_type max_logit > resnet34_imagenet_clip_maha_rank_margin_max_logits.log 2>&1 &

CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 nohup python -m torch.distributed.launch --master_port 7668 --nproc_per_node=8 train_ensemble_imagenet_gambler.py --batch-size 1024 --lr 0.4 --num_classes 1000 --epochs 150 --loss_type gambler --warmup 40 > resnet34_imagenet_gambler.log 2>&1 &

CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 nohup python -m torch.distributed.launch --master_port 7666 --nproc_per_node=8 train_ensemble_imagenet_maha_weight.py --batch-size 512 --lr 0.2 --num_classes 1000 --epochs 120 -a clip32 --maha_file ./ssl/maha_dict_clip32_imagenet_512.npy --loss_type train_weight --warmup 130> resnet34_imagenet_clip_maha_train_weight.log 2>&1 &
CUDA_VISIBLE_DEVICES=1,2,3,4,5,6,7 nohup python -m torch.distributed.launch --master_port 7667 --nproc_per_node=7 train_ensemble_imagenet_maha_weight.py --batch-size 1024 --lr 0.4 --num_classes 1000 --epochs 300 --loss_type rank0 -a clip32 --maha_file ./ssl/maha_dict_clip32_imagenet_512.npy > resnet34_imagenet_weight_conf.log 2>&1 &

CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 nohup python -m torch.distributed.launch --master_port 7667 --nproc_per_node=8 train_ensemble_imagenet_maha_weight.py --batch-size 1536 --lr 0.6 --num_classes 1000 --epochs 300 --loss_type weight_rank_margin2 -a clip32 --maha_file ./ssl/maha_dict_clip32_imagenet_512.npy > resnet34_imagenet_weight_conf_margin2.log 2>&1 &

CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 nohup python -m torch.distributed.launch --master_port 7667 --nproc_per_node=8 train_imagenet_crl.py --batch-size 1536 --lr 0.6 --num_classes 1000 --epochs 200 --loss_type conf --rank_target softmax > resnet34_imagenet_train_crl.log 2>&1 &

CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 nohup python -m torch.distributed.launch --master_port 7667 --nproc_per_node=8 train_ensemble_imagenet_maha_weight_static.py --batch-size 1536 --lr 0.6 --num_classes 1000 --epochs 300 --rank_epo 1000 --loss_type weight_fr80_pca50  --maha_file ./ssl/maha_dist_imagenet_50.npy > resnet34_imagenet_weight_fr80_pca50.log 2>&1 &

CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 nohup python -m torch.distributed.launch --master_port 7667 --nproc_per_node=8 train_ensemble_imagenet_maha_static.py --batch-size 1536 --lr 0.6 --num_classes 1000 --epochs 300 --loss_type rank_margin_fr80_pca50  --maha_file ./ssl/maha_dist_imagenet_50.npy > resnet34_imagenet_max_conf_margin_fr80_pca50.log 2>&1 &

