-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jizong
committed
Jul 25, 2020
1 parent
58485d5
commit 4c052cb
Showing
6 changed files
with
126 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from .contrast_trainer import ContrastTrainer, ContrastTrainerMT | ||
from .iic_trainer import IICContrastTrainer | ||
|
||
trainer_zoos = {"contrast": ContrastTrainer, "contrastMT":ContrastTrainerMT} | ||
trainer_zoos = {"contrast": ContrastTrainer, "contrastMT": ContrastTrainerMT, "iiccontrast": IICContrastTrainer} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import argparse | ||
from itertools import cycle | ||
|
||
from deepclustering2.cchelper import JobSubmiter | ||
|
||
parser = argparse.ArgumentParser() | ||
|
||
parser.add_argument("-l", "--label_ratio", default=0.1, type=float) | ||
parser.add_argument("-n", "--trainer_name", required=True, type=str) | ||
parser.add_argument("-b", "--num_batches", default=100, type=int) | ||
parser.add_argument("-s", "--random_seed", default=1, type=int) | ||
parser.add_argument("-o", "--contrast_on", default="partition", type=str) | ||
parser.add_argument("-c", "--num_clusters", default=40, type=int) | ||
|
||
args = parser.parse_args() | ||
|
||
num_batches = args.num_batches | ||
random_seed = args.random_seed | ||
|
||
labeled_data_ratio = args.label_ratio | ||
unlabeled_data_ratio = 1 - labeled_data_ratio | ||
|
||
trainer_name = args.trainer_name | ||
assert trainer_name == "iiccontrast" | ||
contrast_on = args.contrast_on | ||
save_dir = f"iic_contrast/label_data_ration_{labeled_data_ratio}/{trainer_name}/contrast_on_{contrast_on}" | ||
|
||
common_opts = f" Trainer.name={trainer_name} PretrainEncoder.group_option={contrast_on} " \ | ||
f" RetrainEncoder.num_clusters={args.num_clusters} RandomSeed={random_seed} " \ | ||
f" Data.labeled_data_ratio={labeled_data_ratio} Data.unlabeled_data_ratio={unlabeled_data_ratio} " \ | ||
f" Trainer.num_batches={num_batches} " | ||
if trainer_name == "contrastMT": | ||
common_opts += f" FineTune.reg_weight={args.reg_weight} " | ||
|
||
jobs = [ | ||
f"python -O main_contrast.py {common_opts} Trainer.save_dir={save_dir}/baseline Trainer.train_encoder=False Trainer.train_decoder=False ", | ||
f"python -O main_contrast.py {common_opts} Trainer.save_dir={save_dir}/iic_0.0 Trainer.train_encoder=True Trainer.train_decoder=False PretrainEncoder.iic_weight=0.0", | ||
f"python -O main_contrast.py {common_opts} Trainer.save_dir={save_dir}/iic_0.5 Trainer.train_encoder=True Trainer.train_decoder=False PretrainEncoder.iic_weight=0.5", | ||
f"python -O main_contrast.py {common_opts} Trainer.save_dir={save_dir}/iic_1.0 Trainer.train_encoder=True Trainer.train_decoder=False PretrainEncoder.iic_weight=1.0", | ||
] | ||
|
||
# CC things | ||
accounts = cycle(["def-chdesa", "def-mpederso", "rrg-mpederso"]) | ||
|
||
jobsubmiter = JobSubmiter(project_path="./", on_local=True, time=4) | ||
for j in jobs: | ||
jobsubmiter.prepare_env(["source ./venv/bin/activate ", "export OMP_NUM_THREADS=1", ]) | ||
jobsubmiter.account = next(accounts) | ||
jobsubmiter.run(j) | ||
# print(j) |