{"id":13737924,"url":"https://github.com/MadryLab/copriors","last_synced_at":"2025-05-08T15:32:02.189Z","repository":{"id":86885907,"uuid":"417552765","full_name":"MadryLab/copriors","owner":"MadryLab","description":"Combining Diverse Feature Priors","archived":false,"fork":false,"pushed_at":"2021-10-18T01:35:53.000Z","size":25,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":6,"default_branch":"main","last_synced_at":"2024-11-15T06:32:52.639Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MadryLab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-10-15T15:41:39.000Z","updated_at":"2023-11-27T22:37:40.000Z","dependencies_parsed_at":"2023-05-29T17:15:21.096Z","dependency_job_id":null,"html_url":"https://github.com/MadryLab/copriors","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MadryLab%2Fcopriors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MadryLab%2Fcopriors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MadryLab%2Fcopriors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MadryLab%2Fcopriors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MadryLab","download_url":"https://codeload.github.com/MadryLab/copriors/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253096241,"owners_count":21853565,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T03:02:06.004Z","updated_at":"2025-05-08T15:32:01.927Z","avatar_url":"https://github.com/MadryLab.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Combining Diverse Feature Priors\nThis repository contains code for reproducing the results of our paper.\n\nPaper: https://arxiv.org/abs/2110.08220\n\nBlog Post: http://gradientscience.org/copriors/\n\n\nImportant files:\n```\nScripts:\n  pretrain_model.py: a script to pre-train the models on just the labeled data\n  cotrain.py: a script to co-train pretrained model(s)\n  sweep_final_models.py: a script to evaluate intermediate eras for a previously run cotrain\n  \nFile Structure:\n  datasets:\n    datasets.py: the definition of the labeled/unlabeled/validation/test sets for our datasets\n    transforms.py: describes the different prior transforms and spurious tinting\n    co_training.py: contains the logic for model pre-training and co-training\n   models:\n    bagnet_custom.py: the architecture for the bagnets used in this paper\n    model_utils.py: utilities for loading and building models\n```\n\nTo generate the pre-trained priors, run:\n```\npython pretrain_model.py --dataset \u003cDATASET NAME\u003e --data-path \u003cDATA PATH\u003e --use_val --out-dir \u003cOUTPUT PATH NAME\u003e --arch \u003cARCHITECTURE NAME\u003e --epochs 300 --lr \u003cLR\u003e --step_lr \u003cSTEP LR\u003e --step_lr_gamma \u003cSTEP LR GAMMA\u003e --additional-transform \u003cTRANSFORM TYPE\u003e\n\ndatasets: STLSub10, cifarsmallsub, celebaskewed \ndata-path: use torchvision datasets from https://pytorch.org/vision/stable/index.html\nuse-val: determines whether to use validation or test set for tensorboard metrics\narch: vgg16_bn, bagnetcustom32 (bagnet for CIFAR), bagnetcustom96thin (bagnet for celeba/stl10)\nlr, step-lr, step-lr-gamma are hyperparameters who's exact values can be found in our appendix.\nadditional-transform: which prior to use. possibilities are NONE, CANNY, SOBEL (use NONE and a bagnet architecture for the bagnet prior)\n\nAdd --spurious TINT to train with a tint (as in the tinted STL-10 experiments)\n```\n\nAfter generating the priors, the models can be self (include one prior directory) or co-trained (include both prior directories) by running:\n```\npython cotrain.py --dataset \u003cDATASET NAME\u003e --data-path \u003cDATA PATH\u003e --out-dir \u003cOUTPUT PATH\u003e --input-dirs \u003cPRIOR DIRECTORY 1\u003e --input-dirs \u003cPRIOR DIRECTORY 2\u003e --epochs_per_era 300 --fraction 0.05 --eras 20 --epochs 400 --arch vgg16_bn --additional-transform NONE --lr \u003cLR\u003e --step_lr \u003cSTEP LR\u003e --step_lr_gamma \u003cSTEP LR GAMMA\u003e --strategy STANDARD_CONSTANT \n\nThis command will self/co-train the input prior directories, saving a checkpoint for each era, and then finally train a standard model on the pseudo-labels after the eras are complete.\n\nTo use the pure co-training strategy, add --pure\nTo use tinting as in the STL-10 tinting experiments\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMadryLab%2Fcopriors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMadryLab%2Fcopriors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMadryLab%2Fcopriors/lists"}