├── .gitignore ├── LICENSE ├── README.md ├── archive.py ├── augmentations.py ├── common.py ├── confs └── wresnet28x2.yaml ├── data.py ├── metrics.py ├── networks ├── __init__.py └── wideresnet.py ├── requirements.txt ├── samplers ├── __init__.py └── stratified_sampler.py └── train.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | MANIFEST 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | db.sqlite3 58 | 59 | # Flask stuff: 60 | instance/ 61 | .webassets-cache 62 | 63 | # Scrapy stuff: 64 | .scrapy 65 | 66 | # Sphinx documentation 67 | docs/_build/ 68 | 69 | # PyBuilder 70 | target/ 71 | 72 | # Jupyter Notebook 73 | .ipynb_checkpoints 74 | 75 | # pyenv 76 | .python-version 77 | 78 | # celery beat schedule file 79 | celerybeat-schedule 80 | 81 | # SageMath parsed files 82 | *.sage.py 83 | 84 | # Environments 85 | .env 86 | .venv 87 | env/ 88 | venv/ 89 | ENV/ 90 | env.bak/ 91 | venv.bak/ 92 | 93 | # Spyder project settings 94 | .spyderproject 95 | .spyproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | # mkdocs documentation 101 | /site 102 | 103 | # mypy 104 | .mypy_cache/ 105 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # UDA : Unsupervised Data Augmentation 2 | 3 | Unofficial PyTorch Implementation of [Unsupervised Data Augmentation](https://arxiv.org/abs/1904.12848v1). 4 | 5 | - Experiments on Text Dataset need to be done. Any Pull-Requests would be appreciated. 6 | - Augmentation policies for SVHN, Imagenet using AutoAugment are not available publicly. We use policies from [Fast AutoAugment](https://github.com/kakaobrain/fast-autoaugment). 7 | 8 | Most of codes are from [Fast AutoAugment](https://github.com/kakaobrain/fast-autoaugment). 9 | 10 | ## Introduction 11 | 12 | todo. 13 | 14 | ## Run 15 | 16 | ``` 17 | $ python train.py -c confs/wresnet28x2.yaml --unsupervised 18 | ``` 19 | 20 | ## Experiments 21 | 22 | ### Cifar10 (Reduced, 4k dataset) 23 | 24 | #### Reproduce Paper's Result 25 | 26 | | WResNet 28x2 | Paper | Our Converged(Top1 Err) | Our Best(Top1 Err) | 27 | |--------------|---------:|---------:|---------:| 28 | | Supervised | 20.26 | 21.30 | 29 | | AutoAugment | 14.1* | 15.4 | 13.4 | 30 | | UDA | 5.27 | 6.58 | 6.27 | 31 | 32 | ### SVHN 33 | 34 | todo. 35 | 36 | ### ImageNet 37 | 38 | todo. 39 | 40 | ## References 41 | 42 | - Unsupervised Data Augmentation : https://arxiv.org/abs/1904.12848v1 43 | - Official Tensorflow Implementation : https://github.com/google-research/uda 44 | - Fast AutoAugment : https://github.com/kakaobrain/fast-autoaugment 45 | -------------------------------------------------------------------------------- /archive.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | from __future__ import division 3 | from __future__ import print_function 4 | 5 | from collections import defaultdict 6 | 7 | from augmentations import get_augment 8 | 9 | 10 | def autoaug2arsaug(f): 11 | def autoaug(): 12 | mapper = defaultdict(lambda: lambda x: x) 13 | mapper.update({ 14 | 'ShearX': lambda x: float_parameter(x, 0.3), 15 | 'ShearY': lambda x: float_parameter(x, 0.3), 16 | 'TranslateX': lambda x: int_parameter(x, 10), 17 | 'TranslateY': lambda x: int_parameter(x, 10), 18 | 'Rotate': lambda x: int_parameter(x, 30), 19 | 'Solarize': lambda x: 256 - int_parameter(x, 256), 20 | 'Posterize2': lambda x: 4 - int_parameter(x, 4), 21 | 'Contrast': lambda x: float_parameter(x, 1.8) + .1, 22 | 'Color': lambda x: float_parameter(x, 1.8) + .1, 23 | 'Brightness': lambda x: float_parameter(x, 1.8) + .1, 24 | 'Sharpness': lambda x: float_parameter(x, 1.8) + .1, 25 | 'CutoutAbs': lambda x: int_parameter(x, 20) 26 | }) 27 | 28 | def low_high(name, prev_value): 29 | _, low, high = get_augment(name) 30 | return float(prev_value - low) / (high - low) 31 | 32 | policies = f() 33 | new_policies = [] 34 | for policy in policies: 35 | new_policies.append([(name, pr, low_high(name, mapper[name](level))) for name, pr, level in policy]) 36 | return new_policies 37 | 38 | return autoaug 39 | 40 | 41 | @autoaug2arsaug 42 | def autoaug_paper_cifar10(): 43 | return [ 44 | [('Invert', 0.1, 7), ('Contrast', 0.2, 6)], 45 | [('Rotate', 0.7, 2), ('TranslateXAbs', 0.3, 9)], 46 | [('Sharpness', 0.8, 1), ('Sharpness', 0.9, 3)], 47 | [('ShearY', 0.5, 8), ('TranslateYAbs', 0.7, 9)], 48 | [('AutoContrast', 0.5, 8), ('Equalize', 0.9, 2)], 49 | [('ShearY', 0.2, 7), ('Posterize2', 0.3, 7)], 50 | [('Color', 0.4, 3), ('Brightness', 0.6, 7)], 51 | [('Sharpness', 0.3, 9), ('Brightness', 0.7, 9)], 52 | [('Equalize', 0.6, 5), ('Equalize', 0.5, 1)], 53 | [('Contrast', 0.6, 7), ('Sharpness', 0.6, 5)], 54 | [('Color', 0.7, 7), ('TranslateXAbs', 0.5, 8)], 55 | [('Equalize', 0.3, 7), ('AutoContrast', 0.4, 8)], 56 | [('TranslateYAbs', 0.4, 3), ('Sharpness', 0.2, 6)], 57 | [('Brightness', 0.9, 6), ('Color', 0.2, 6)], 58 | [('Solarize', 0.5, 2), ('Invert', 0.0, 3)], 59 | [('Equalize', 0.2, 0), ('AutoContrast', 0.6, 0)], 60 | [('Equalize', 0.2, 8), ('Equalize', 0.6, 4)], 61 | [('Color', 0.9, 9), ('Equalize', 0.6, 6)], 62 | [('AutoContrast', 0.8, 4), ('Solarize', 0.2, 8)], 63 | [('Brightness', 0.1, 3), ('Color', 0.7, 0)], 64 | [('Solarize', 0.4, 5), ('AutoContrast', 0.9, 3)], 65 | [('TranslateYAbs', 0.9, 9), ('TranslateYAbs', 0.7, 9)], 66 | [('AutoContrast', 0.9, 2), ('Solarize', 0.8, 3)], 67 | [('Equalize', 0.8, 8), ('Invert', 0.1, 3)], 68 | [('TranslateYAbs', 0.7, 9), ('AutoContrast', 0.9, 1)], 69 | ] 70 | 71 | 72 | @autoaug2arsaug 73 | def autoaug_policy(): 74 | """AutoAugment policies found on Cifar.""" 75 | exp0_0 = [ 76 | [('Invert', 0.1, 7), ('Contrast', 0.2, 6)], 77 | [('Rotate', 0.7, 2), ('TranslateXAbs', 0.3, 9)], 78 | [('Sharpness', 0.8, 1), ('Sharpness', 0.9, 3)], 79 | [('ShearY', 0.5, 8), ('TranslateYAbs', 0.7, 9)], 80 | [('AutoContrast', 0.5, 8), ('Equalize', 0.9, 2)]] 81 | exp0_1 = [ 82 | [('Solarize', 0.4, 5), ('AutoContrast', 0.9, 3)], 83 | [('TranslateYAbs', 0.9, 9), ('TranslateYAbs', 0.7, 9)], 84 | [('AutoContrast', 0.9, 2), ('Solarize', 0.8, 3)], 85 | [('Equalize', 0.8, 8), ('Invert', 0.1, 3)], 86 | [('TranslateYAbs', 0.7, 9), ('AutoContrast', 0.9, 1)]] 87 | exp0_2 = [ 88 | [('Solarize', 0.4, 5), ('AutoContrast', 0.0, 2)], 89 | [('TranslateYAbs', 0.7, 9), ('TranslateYAbs', 0.7, 9)], 90 | [('AutoContrast', 0.9, 0), ('Solarize', 0.4, 3)], 91 | [('Equalize', 0.7, 5), ('Invert', 0.1, 3)], 92 | [('TranslateYAbs', 0.7, 9), ('TranslateYAbs', 0.7, 9)]] 93 | exp0_3 = [ 94 | [('Solarize', 0.4, 5), ('AutoContrast', 0.9, 1)], 95 | [('TranslateYAbs', 0.8, 9), ('TranslateYAbs', 0.9, 9)], 96 | [('AutoContrast', 0.8, 0), ('TranslateYAbs', 0.7, 9)], 97 | [('TranslateYAbs', 0.2, 7), ('Color', 0.9, 6)], 98 | [('Equalize', 0.7, 6), ('Color', 0.4, 9)]] 99 | exp1_0 = [ 100 | [('ShearY', 0.2, 7), ('Posterize2', 0.3, 7)], 101 | [('Color', 0.4, 3), ('Brightness', 0.6, 7)], 102 | [('Sharpness', 0.3, 9), ('Brightness', 0.7, 9)], 103 | [('Equalize', 0.6, 5), ('Equalize', 0.5, 1)], 104 | [('Contrast', 0.6, 7), ('Sharpness', 0.6, 5)]] 105 | exp1_1 = [ 106 | [('Brightness', 0.3, 7), ('AutoContrast', 0.5, 8)], 107 | [('AutoContrast', 0.9, 4), ('AutoContrast', 0.5, 6)], 108 | [('Solarize', 0.3, 5), ('Equalize', 0.6, 5)], 109 | [('TranslateYAbs', 0.2, 4), ('Sharpness', 0.3, 3)], 110 | [('Brightness', 0.0, 8), ('Color', 0.8, 8)]] 111 | exp1_2 = [ 112 | [('Solarize', 0.2, 6), ('Color', 0.8, 6)], 113 | [('Solarize', 0.2, 6), ('AutoContrast', 0.8, 1)], 114 | [('Solarize', 0.4, 1), ('Equalize', 0.6, 5)], 115 | [('Brightness', 0.0, 0), ('Solarize', 0.5, 2)], 116 | [('AutoContrast', 0.9, 5), ('Brightness', 0.5, 3)]] 117 | exp1_3 = [ 118 | [('Contrast', 0.7, 5), ('Brightness', 0.0, 2)], 119 | [('Solarize', 0.2, 8), ('Solarize', 0.1, 5)], 120 | [('Contrast', 0.5, 1), ('TranslateYAbs', 0.2, 9)], 121 | [('AutoContrast', 0.6, 5), ('TranslateYAbs', 0.0, 9)], 122 | [('AutoContrast', 0.9, 4), ('Equalize', 0.8, 4)]] 123 | exp1_4 = [ 124 | [('Brightness', 0.0, 7), ('Equalize', 0.4, 7)], 125 | [('Solarize', 0.2, 5), ('Equalize', 0.7, 5)], 126 | [('Equalize', 0.6, 8), ('Color', 0.6, 2)], 127 | [('Color', 0.3, 7), ('Color', 0.2, 4)], 128 | [('AutoContrast', 0.5, 2), ('Solarize', 0.7, 2)]] 129 | exp1_5 = [ 130 | [('AutoContrast', 0.2, 0), ('Equalize', 0.1, 0)], 131 | [('ShearY', 0.6, 5), ('Equalize', 0.6, 5)], 132 | [('Brightness', 0.9, 3), ('AutoContrast', 0.4, 1)], 133 | [('Equalize', 0.8, 8), ('Equalize', 0.7, 7)], 134 | [('Equalize', 0.7, 7), ('Solarize', 0.5, 0)]] 135 | exp1_6 = [ 136 | [('Equalize', 0.8, 4), ('TranslateYAbs', 0.8, 9)], 137 | [('TranslateYAbs', 0.8, 9), ('TranslateYAbs', 0.6, 9)], 138 | [('TranslateYAbs', 0.9, 0), ('TranslateYAbs', 0.5, 9)], 139 | [('AutoContrast', 0.5, 3), ('Solarize', 0.3, 4)], 140 | [('Solarize', 0.5, 3), ('Equalize', 0.4, 4)]] 141 | exp2_0 = [ 142 | [('Color', 0.7, 7), ('TranslateXAbs', 0.5, 8)], 143 | [('Equalize', 0.3, 7), ('AutoContrast', 0.4, 8)], 144 | [('TranslateYAbs', 0.4, 3), ('Sharpness', 0.2, 6)], 145 | [('Brightness', 0.9, 6), ('Color', 0.2, 8)], 146 | [('Solarize', 0.5, 2), ('Invert', 0.0, 3)]] 147 | exp2_1 = [ 148 | [('AutoContrast', 0.1, 5), ('Brightness', 0.0, 0)], 149 | [('CutoutAbs', 0.2, 4), ('Equalize', 0.1, 1)], 150 | [('Equalize', 0.7, 7), ('AutoContrast', 0.6, 4)], 151 | [('Color', 0.1, 8), ('ShearY', 0.2, 3)], 152 | [('ShearY', 0.4, 2), ('Rotate', 0.7, 0)]] 153 | exp2_2 = [ 154 | [('ShearY', 0.1, 3), ('AutoContrast', 0.9, 5)], 155 | [('TranslateYAbs', 0.3, 6), ('CutoutAbs', 0.3, 3)], 156 | [('Equalize', 0.5, 0), ('Solarize', 0.6, 6)], 157 | [('AutoContrast', 0.3, 5), ('Rotate', 0.2, 7)], 158 | [('Equalize', 0.8, 2), ('Invert', 0.4, 0)]] 159 | exp2_3 = [ 160 | [('Equalize', 0.9, 5), ('Color', 0.7, 0)], 161 | [('Equalize', 0.1, 1), ('ShearY', 0.1, 3)], 162 | [('AutoContrast', 0.7, 3), ('Equalize', 0.7, 0)], 163 | [('Brightness', 0.5, 1), ('Contrast', 0.1, 7)], 164 | [('Contrast', 0.1, 4), ('Solarize', 0.6, 5)]] 165 | exp2_4 = [ 166 | [('Solarize', 0.2, 3), ('ShearX', 0.0, 0)], 167 | [('TranslateXAbs', 0.3, 0), ('TranslateXAbs', 0.6, 0)], 168 | [('Equalize', 0.5, 9), ('TranslateYAbs', 0.6, 7)], 169 | [('ShearX', 0.1, 0), ('Sharpness', 0.5, 1)], 170 | [('Equalize', 0.8, 6), ('Invert', 0.3, 6)]] 171 | exp2_5 = [ 172 | [('AutoContrast', 0.3, 9), ('CutoutAbs', 0.5, 3)], 173 | [('ShearX', 0.4, 4), ('AutoContrast', 0.9, 2)], 174 | [('ShearX', 0.0, 3), ('Posterize2', 0.0, 3)], 175 | [('Solarize', 0.4, 3), ('Color', 0.2, 4)], 176 | [('Equalize', 0.1, 4), ('Equalize', 0.7, 6)]] 177 | exp2_6 = [ 178 | [('Equalize', 0.3, 8), ('AutoContrast', 0.4, 3)], 179 | [('Solarize', 0.6, 4), ('AutoContrast', 0.7, 6)], 180 | [('AutoContrast', 0.2, 9), ('Brightness', 0.4, 8)], 181 | [('Equalize', 0.1, 0), ('Equalize', 0.0, 6)], 182 | [('Equalize', 0.8, 4), ('Equalize', 0.0, 4)]] 183 | exp2_7 = [ 184 | [('Equalize', 0.5, 5), ('AutoContrast', 0.1, 2)], 185 | [('Solarize', 0.5, 5), ('AutoContrast', 0.9, 5)], 186 | [('AutoContrast', 0.6, 1), ('AutoContrast', 0.7, 8)], 187 | [('Equalize', 0.2, 0), ('AutoContrast', 0.1, 2)], 188 | [('Equalize', 0.6, 9), ('Equalize', 0.4, 4)]] 189 | exp0s = exp0_0 + exp0_1 + exp0_2 + exp0_3 190 | exp1s = exp1_0 + exp1_1 + exp1_2 + exp1_3 + exp1_4 + exp1_5 + exp1_6 191 | exp2s = exp2_0 + exp2_1 + exp2_2 + exp2_3 + exp2_4 + exp2_5 + exp2_6 + exp2_7 192 | 193 | return exp0s + exp1s + exp2s 194 | 195 | 196 | @autoaug2arsaug 197 | def svhn_policies(): 198 | policies = [ 199 | [("ShearX", 0.9, 4), ("Invert", 0.2, 3)], 200 | [("ShearY", 0.9, 8), ("Invert", 0.7, 5)], 201 | [("Equalize", 0.6, 5), ("Solarize", 0.6, 6)], 202 | [("Invert", 0.9, 3), ("Equalize", 0.6, 3)], 203 | [("Equalize", 0.6, 1), ("Rotate", 0.9, 3)], 204 | [("ShearX", 0.9, 4), ("AutoContrast", 0.8, 3)], 205 | [("ShearY", 0.9, 8), ("Invert", 0.4, 5)], 206 | [("ShearY", 0.9, 5), ("Solarize", 0.2, 6)], 207 | [("Invert", 0.9, 6), ("AutoContrast", 0.8, 1)], 208 | [("Equalize", 0.6, 3), ("Rotate", 0.9, 3)], 209 | [("ShearX", 0.9, 4), ("Solarize", 0.3, 3)], 210 | [("ShearY", 0.8, 8), ("Invert", 0.7, 4)], 211 | [("Equalize", 0.9, 5), ("TranslateY", 0.6, 6)], 212 | [("Invert", 0.9, 4), ("Equalize", 0.6, 7)], 213 | [("Contrast", 0.3, 3), ("Rotate", 0.8, 4)], 214 | [("ShearX", 0.9, 3), ("Invert", 0.5, 3)], 215 | [("ShearY", 0.9, 8), ("Invert", 0.4, 5)], 216 | [("Equalize", 0.6, 3), ("Solarize", 0.2, 3)], 217 | [("Invert", 0.9, 4), ("Equalize", 0.5, 6)], 218 | [("Equalize", 0.6, 1), ("Rotate", 0.9, 3)], 219 | [("Invert", 0.8, 5), ("TranslateY", 0.0, 2)], 220 | [("ShearY", 0.7, 6), ("Solarize", 0.4, 8)], 221 | [("Invert", 0.6, 4), ("Rotate", 0.8, 4)], 222 | [("ShearY", 0.3, 7), ("TranslateX", 0.9, 3)], 223 | [("ShearX", 0.1, 6), ("Invert", 0.6, 5)], 224 | [("Solarize", 0.7, 2), ("TranslateY", 0.6, 7)], 225 | [("ShearY", 0.8, 4), ("Invert", 0.8, 8)], 226 | [("ShearX", 0.7, 9), ("TranslateY", 0.8, 3)], 227 | [("ShearY", 0.8, 5), ("AutoContrast", 0.7, 3)], 228 | [("ShearX", 0.7, 2), ("Invert", 0.1, 5)], 229 | [("ShearY", 0.8, 9), ("ShearX", 0.7, 7)], 230 | [("ShearY", 0.7, 4), ("Solarize", 0.9, 7)], 231 | [("ShearY", 0.9, 5), ("Invert", 0.0, 4)], 232 | [("TranslateX", 0.8, 3), ("ShearY", 0.7, 7)], 233 | [("Invert", 0.1, 7), ("Solarize", 0.3, 9)], 234 | [("Invert", 0.6, 2), ("Invert", 0.9, 4)], 235 | [("Equalize", 0.5, 2), ("Solarize", 0.9, 7)], 236 | [("ShearY", 0.6, 7), ("Solarize", 0.8, 3)], 237 | [("ShearY", 0.6, 3), ("Invert", 0.6, 1)], 238 | [("ShearX", 0.4, 2), ("Rotate", 0.7, 5)]] 239 | 240 | return policies 241 | 242 | 243 | @autoaug2arsaug 244 | def autoaug_imagenet_policy(): 245 | policies = [ 246 | [("Posterize", 0.4, 8), ("Rotate", 0.6, 9)], 247 | [("Solarize", 0.6, 5), ("AutoContrast", 0.6, 5)], 248 | [("Equalize", 0.8, 8), ("Equalize", 0.6, 3)], 249 | [("Posterize", 0.6, 7), ("Posterize", 0.6, 6)], 250 | [("Equalize", 0.4, 7), ("Solarize", 0.2, 4)], 251 | [("Equalize", 0.4, 4), ("Rotate", 0.8, 8)], 252 | [("Solarize", 0.6, 3), ("Equalize", 0.6, 7)], 253 | [("Posterize", 0.8, 5), ("Equalize", 1.0, 2)], 254 | [("Rotate", 0.2, 3), ("Solarize", 0.6, 8)], 255 | [("Equalize", 0.6, 8), ("Posterize", 0.4, 6)], 256 | [("Rotate", 0.8, 8), ("Color", 0.4, 0)], 257 | [("Rotate", 0.4, 9), ("Equalize", 0.6, 2)], 258 | [("Equalize", 0.0, 7), ("Equalize", 0.8, 8)], 259 | [("Invert", 0.6, 4), ("Equalize", 1.0, 8)], 260 | [("Color", 0.6, 4), ("Contrast", 1.0, 8)], 261 | [("Rotate", 0.8, 8), ("Color", 1.0, 2)], 262 | [("Color", 0.8, 8), ("Solarize", 0.8, 7)], 263 | [("Sharpness", 0.4, 7), ("Invert", 0.6, 8)], 264 | [("ShearX", 0.6, 5), ("Equalize", 1.0, 9)], 265 | [("Color", 0.4, 0), ("Equalize", 0.6, 3)] 266 | ] 267 | return policies 268 | 269 | 270 | PARAMETER_MAX = 10 271 | 272 | 273 | def float_parameter(level, maxval): 274 | return float(level) * maxval / PARAMETER_MAX 275 | 276 | 277 | def int_parameter(level, maxval): 278 | return int(float_parameter(level, maxval)) 279 | 280 | 281 | def no_duplicates(f): 282 | def wrap_remove_duplicates(): 283 | policies = f() 284 | return remove_duplicates(policies) 285 | 286 | return wrap_remove_duplicates 287 | 288 | 289 | def remove_duplicates(policies): 290 | s = set() 291 | new_policies = [] 292 | for ops in policies: 293 | key = [] 294 | for op in ops: 295 | key.append(op[0]) 296 | key = '_'.join(key) 297 | if key in s: 298 | continue 299 | else: 300 | s.add(key) 301 | new_policies.append(ops) 302 | 303 | return new_policies 304 | 305 | 306 | def fa_reduced_cifar10(): 307 | p = [[["Contrast", 0.8320659688593578, 0.49884310562180767], ["TranslateX", 0.41849883971249136, 0.394023086494538]], [["Color", 0.3500483749890918, 0.43355143929883955], ["Color", 0.5120716140300229, 0.7508299643325016]], [["Rotate", 0.9447932604389472, 0.29723465088990375], ["Sharpness", 0.1564936149799504, 0.47169309978091745]], [["Rotate", 0.5430015349185097, 0.6518626678905443], ["Color", 0.5694844928020679, 0.3494533005430269]], [["AutoContrast", 0.5558922032451064, 0.783136004977799], ["TranslateY", 0.683914191471972, 0.7597025305860181]], [["TranslateX", 0.03489224481658926, 0.021025488042663354], ["Equalize", 0.4788637403857401, 0.3535481281496117]], [["Sharpness", 0.6428916269794158, 0.22791511918580576], ["Contrast", 0.016014045073950323, 0.26811312269487575]], [["Rotate", 0.2972727228410451, 0.7654251516829896], ["AutoContrast", 0.16005809254943348, 0.5380523650108116]], [["Contrast", 0.5823671057717301, 0.7521166301398389], ["TranslateY", 0.9949449214751978, 0.9612671341689751]], [["Equalize", 0.8372126687702321, 0.6944127225621206], ["Rotate", 0.25393282929784755, 0.3261658365286546]], [["Invert", 0.8222011603194572, 0.6597915864008403], ["Posterize", 0.31858707654447327, 0.9541013715579584]], [["Sharpness", 0.41314621282107045, 0.9437344470879956], ["Cutout", 0.6610495837889337, 0.674411664255093]], [["Contrast", 0.780121736705407, 0.40826152397463156], ["Color", 0.344019192125256, 0.1942922781355767]], [["Rotate", 0.17153139555621344, 0.798745732456474], ["Invert", 0.6010555860501262, 0.320742172554767]], [["Invert", 0.26816063450777416, 0.27152062163148327], ["Equalize", 0.6786829200236982, 0.7469412443514213]], [["Contrast", 0.3920564414367518, 0.7493644582838497], ["TranslateY", 0.8941657805606704, 0.6580846856375955]], [["Equalize", 0.875509207399372, 0.9061130537645283], ["Cutout", 0.4940280679087308, 0.7896229623628276]], [["Contrast", 0.3331423298065147, 0.7170041362529597], ["ShearX", 0.7425484291842793, 0.5285117152426109]], [["Equalize", 0.97344237365026, 0.4745759720473106], ["TranslateY", 0.055863458430295276, 0.9625142022954672]], [["TranslateX", 0.6810614083109192, 0.7509937355495521], ["TranslateY", 0.3866463019475701, 0.5185481505576112]], [["Sharpness", 0.4751529944753671, 0.550464012488733], ["Cutout", 0.9472914750534814, 0.5584925992985023]], [["Contrast", 0.054606784909375095, 0.17257080196712182], ["Cutout", 0.6077026782754803, 0.7996504165944938]], [["ShearX", 0.328798428243695, 0.2769563264079157], ["Cutout", 0.9037632437023772, 0.4915809476763595]], [["Cutout", 0.6891202672363478, 0.9951490996172914], ["Posterize", 0.06532762462628705, 0.4005246609075227]], [["TranslateY", 0.6908583592523334, 0.725612120376128], ["Rotate", 0.39907735501746666, 0.36505798032223147]], [["TranslateX", 0.10398364107399072, 0.5913918470536627], ["Rotate", 0.7169811539340365, 0.8283850670648724]], [["ShearY", 0.9526373530768361, 0.4482347365639251], ["Contrast", 0.4203947336351471, 0.41526799558953864]], [["Contrast", 0.24894431199700073, 0.09578870500994707], ["Solarize", 0.2273713345927395, 0.6214942914963707]], [["TranslateX", 0.06331228870032912, 0.8961907489444944], ["Cutout", 0.5110007859958743, 0.23704875994050723]], [["Cutout", 0.3769183548846172, 0.6560944580253987], ["TranslateY", 0.7201924599434143, 0.4132476526938319]], [["Invert", 0.6707431156338866, 0.11622795952464149], ["Posterize", 0.12075972752370845, 0.18024933294172307]], [["Color", 0.5010057264087142, 0.5277767327434318], ["Rotate", 0.9486115946366559, 0.31485546630220784]], [["ShearX", 0.31741302466630406, 0.1991215806270692], ["Invert", 0.3744727015523084, 0.6914113986757578]], [["Brightness", 0.40348479064392617, 0.8924182735724888], ["Brightness", 0.1973098763857779, 0.3939288933689655]], [["Color", 0.01208688664030888, 0.6055693000885217], ["Equalize", 0.433259451147881, 0.420711137966155]], [["Cutout", 0.2620018360076487, 0.11594468278143644], ["Rotate", 0.1310401567856766, 0.7244318146544101]], [["ShearX", 0.15249651845933576, 0.35277277071866986], ["Contrast", 0.28221794032094016, 0.42036586509397444]], [["Brightness", 0.8492912150468908, 0.26386920887886056], ["Solarize", 0.8764208056263386, 0.1258195122766067]], [["ShearX", 0.8537058239675831, 0.8415101816171269], ["AutoContrast", 0.23958568830416294, 0.9889049529564014]], [["Rotate", 0.6463207930684552, 0.8750192129056532], ["Contrast", 0.6865032211768652, 0.8564981333033417]], [["Equalize", 0.8877190311811044, 0.7370995897848609], ["TranslateX", 0.9979660314391368, 0.005683998913244781]], [["Color", 0.6420017551677819, 0.6225337265571229], ["Solarize", 0.8344504978566362, 0.8332856969941151]], [["ShearX", 0.7439332981992567, 0.9747608698582039], ["Equalize", 0.6259189804002959, 0.028017478098245174]], [["TranslateY", 0.39794770293366843, 0.8482966537902709], ["Rotate", 0.9312935630405351, 0.5300586925826072]], [["Cutout", 0.8904075572021911, 0.3522934742068766], ["Equalize", 0.6431186289473937, 0.9930577962126151]], [["Contrast", 0.9183553386089476, 0.44974266209396685], ["TranslateY", 0.8193684583123862, 0.9633741156526566]], [["ShearY", 0.616078299924283, 0.19219314358924766], ["Solarize", 0.1480945914138868, 0.05922109541654652]], [["Solarize", 0.25332455064128157, 0.18853037431947994], ["ShearY", 0.9518390093954243, 0.14603930044061142]], [["Color", 0.8094378664335412, 0.37029830225408433], ["Contrast", 0.29504113617467465, 0.065096365468442]], [["AutoContrast", 0.7075167558685455, 0.7084621693458267], ["Sharpness", 0.03555539453323875, 0.5651948313888351]], [["TranslateY", 0.5969982600930229, 0.9857264201029572], ["Rotate", 0.9898628564873607, 0.1985685534926911]], [["Invert", 0.14915939942810352, 0.6595839632446547], ["Posterize", 0.768535289994361, 0.5997358684618563]], [["Equalize", 0.9162691815967111, 0.3331035307653627], ["Color", 0.8169118187605557, 0.7653910258006366]], [["Rotate", 0.43489185299530897, 0.752215269135173], ["Brightness", 0.1569828560334806, 0.8002808712857853]], [["Invert", 0.931876215328345, 0.029428644395760872], ["Equalize", 0.6330036052674145, 0.7235531014288485]], [["ShearX", 0.5216138393704968, 0.849272958911589], ["AutoContrast", 0.19572688655120263, 0.9786551568639575]], [["ShearX", 0.9899586208275011, 0.22580547500610293], ["Brightness", 0.9831311903178727, 0.5055159610855606]], [["Brightness", 0.29179117009211486, 0.48003584672937294], ["Solarize", 0.7544252317330058, 0.05806581735063043]], [["AutoContrast", 0.8919800329537786, 0.8511261613698553], ["Contrast", 0.49199446084551035, 0.7302297140181429]], [["Cutout", 0.7079723710644835, 0.032565015538375874], ["AutoContrast", 0.8259782090388609, 0.7860708789468442]], [["Posterize", 0.9980262659801914, 0.6725084224935673], ["ShearY", 0.6195568269664682, 0.5444170291816751]], [["Posterize", 0.8687351834713217, 0.9978004914422602], ["Equalize", 0.4532646848325955, 0.6486748015710573]], [["Contrast", 0.2713928776950594, 0.15255249557027806], ["ShearY", 0.9276834387970199, 0.5266542862333478]], [["AutoContrast", 0.5240786618055582, 0.9325642258930253], ["Cutout", 0.38448627892037357, 0.21219415055662394]], [["TranslateX", 0.4299517937295352, 0.20133751201386152], ["TranslateX", 0.6753468310276597, 0.6985621035400441]], [["Rotate", 0.4006472499103597, 0.6704748473357586], ["Equalize", 0.674161668148079, 0.6528530101705237]], [["Equalize", 0.9139902833674455, 0.9015103149680278], ["Sharpness", 0.7289667720691948, 0.7623606352376232]], [["Cutout", 0.5911267429414259, 0.5953141187177585], ["Rotate", 0.5219064817468504, 0.11085141355857986]], [["TranslateX", 0.3620095133946267, 0.26194039409492476], ["Rotate", 0.3929841359545597, 0.4913406720338047]], [["Invert", 0.5175298901458896, 0.001661410821811482], ["Invert", 0.004656581318332242, 0.8157622192213624]], [["AutoContrast", 0.013609693335051465, 0.9318651749409604], ["Invert", 0.8980844358979592, 0.2268511862780368]], [["ShearY", 0.7717126261142194, 0.09975547983707711], ["Equalize", 0.7808494401429572, 0.4141412091009955]], [["TranslateX", 0.5878675721341552, 0.29813268038163376], ["Posterize", 0.21257276051591356, 0.2837285296666412]], [["Brightness", 0.4268335108566488, 0.4723784991635417], ["Cutout", 0.9386262901570471, 0.6597686851494288]], [["ShearX", 0.8259423807590159, 0.6215304795389204], ["Invert", 0.6663365779667443, 0.7729669184580387]], [["ShearY", 0.4801338723951297, 0.5220145420100984], ["Solarize", 0.9165803796596582, 0.04299335502862134]], [["Color", 0.17621114853558817, 0.7092601754635434], ["ShearX", 0.9014406936728542, 0.6028711944367818]], [["Rotate", 0.13073284972300658, 0.9088831512880851], ["ShearX", 0.4228105332316806, 0.7985249783662675]], [["Brightness", 0.9182753692730031, 0.0063635477774044436], ["Color", 0.4279825602663798, 0.28727149118585327]], [["Equalize", 0.578218285372267, 0.9611758542158054], ["Contrast", 0.5471552264150691, 0.8819635504027596]], [["Brightness", 0.3208589067274543, 0.45324733565167497], ["Solarize", 0.5218455808633233, 0.5946097503647126]], [["Equalize", 0.3790381278653, 0.8796082535775276], ["Solarize", 0.4875526773149246, 0.5186585878052613]], [["ShearY", 0.12026461479557571, 0.1336953429068397], ["Posterize", 0.34373988646025766, 0.8557727670803785]], [["Cutout", 0.2396745247507467, 0.8123036135209865], ["Equalize", 0.05022807681008945, 0.6648492261984383]], [["Brightness", 0.35226676470748264, 0.5950011514888855], ["Rotate", 0.27555076067000894, 0.9170063321486026]], [["ShearX", 0.320224630647278, 0.9683584649071976], ["Invert", 0.6905585196648905, 0.5929115667894518]], [["Color", 0.9941395717559652, 0.7474441679798101], ["Sharpness", 0.7559998478658021, 0.6656052889626682]], [["ShearY", 0.4004220568345669, 0.5737646992826074], ["Equalize", 0.9983495213746147, 0.8307907033362303]], [["Color", 0.13726809242038207, 0.9378850119950549], ["Equalize", 0.9853362454752445, 0.42670264496554156]], [["Invert", 0.13514636153298576, 0.13516363849081958], ["Sharpness", 0.2031189356693901, 0.6110226359872745]], [["TranslateX", 0.7360305209630797, 0.41849698571655614], ["Contrast", 0.8972161549144564, 0.7820296625565641]], [["Color", 0.02713118828682548, 0.717110684828096], ["TranslateY", 0.8118759006836348, 0.9120098002024992]], [["Sharpness", 0.2915428949403711, 0.7630303724396518], ["Solarize", 0.22030536162851078, 0.38654526772661757]], [["Equalize", 0.9949114839538582, 0.7193630656062793], ["AutoContrast", 0.00889496657931299, 0.2291400476524672]], [["Rotate", 0.7120948976490488, 0.7804359309791055], ["Cutout", 0.10445418104923654, 0.8022999156052766]], [["Equalize", 0.7941710117902707, 0.8648170634288153], ["Invert", 0.9235642581144047, 0.23810725859722381]], [["Cutout", 0.3669397998623156, 0.42612815083245004], ["Solarize", 0.5896322046441561, 0.40525016166956795]], [["Color", 0.8389858785714184, 0.4805764176488667], ["Rotate", 0.7483931487048825, 0.4731174601400677]], [["Sharpness", 0.19006538611394763, 0.9480745790240234], ["TranslateY", 0.13904429049439282, 0.04117685330615939]], [["TranslateY", 0.9958097661701637, 0.34853788612580905], ["Cutout", 0.2235829624082113, 0.3737887095480745]], [["ShearX", 0.635453761342424, 0.6063917273421382], ["Posterize", 0.8738297843709666, 0.4893042590265556]], [["Brightness", 0.7907245198402727, 0.7082189713070691], ["Color", 0.030313003541849737, 0.6927897798493439]], [["Cutout", 0.6965622481073525, 0.8103522907758203], ["ShearY", 0.6186794303078708, 0.28640671575703547]], [["ShearY", 0.43734910588450226, 0.32549342535621517], ["ShearX", 0.08154980987651872, 0.3286764923112455]], [["AutoContrast", 0.5262462005050853, 0.8175584582465848], ["Contrast", 0.8683217097363655, 0.548776281479276]], [["ShearY", 0.03957878500311707, 0.5102350637943197], ["Rotate", 0.13794708520303778, 0.38035687712954236]], [["Sharpness", 0.634288567312677, 0.6387948309075822], ["AutoContrast", 0.13437288694693272, 0.7150448869023095]], [["Contrast", 0.5198339640088544, 0.9409429390321714], ["Cutout", 0.09489154903321972, 0.6228488803821982]], [["Equalize", 0.8955909061806043, 0.7727336527163008], ["AutoContrast", 0.6459479564441762, 0.7065467781139214]], [["Invert", 0.07214420843537739, 0.15334721382249505], ["ShearX", 0.9242027778363903, 0.5809187849982554]], [["Equalize", 0.9144084379856188, 0.9457539278608998], ["Sharpness", 0.14337499858300173, 0.5978054365425495]], [["Posterize", 0.18894269796951202, 0.14676331276539045], ["Equalize", 0.846204299950047, 0.0720601838168885]], [["Contrast", 0.47354445405741163, 0.1793650330107468], ["Solarize", 0.9086106327264657, 0.7578807802091502]], [["AutoContrast", 0.11805466892967886, 0.6773620948318575], ["TranslateX", 0.584222568299264, 0.9475693349391936]], [["Brightness", 0.5833017701352768, 0.6892593824176294], ["AutoContrast", 0.9073141314561828, 0.5823085733964589]], [["TranslateY", 0.5711231614144834, 0.6436240447620021], ["Contrast", 0.21466964050052473, 0.8042843954486391]], [["Contrast", 0.22967904487976765, 0.2343103109298762], ["Invert", 0.5502897289159286, 0.386181060792375]], [["Invert", 0.7008423439928628, 0.4234003051405053], ["Rotate", 0.77270460187611, 0.6650852696828039]], [["Invert", 0.050618322309703534, 0.24277027926683614], ["TranslateX", 0.789703489736613, 0.5116446685339312]], [["Color", 0.363898083076868, 0.7870323584210503], ["ShearY", 0.009608425513626617, 0.6188625018465327]], [["TranslateY", 0.9447601615216088, 0.8605867115798349], ["Equalize", 0.24139180127003634, 0.9587337957930782]], [["Equalize", 0.3968589440144503, 0.626206375426996], ["Solarize", 0.3215967960673186, 0.826785464835443]], [["TranslateX", 0.06947339047121326, 0.016705969558222122], ["Contrast", 0.6203392406528407, 0.6433525559906872]], [["Solarize", 0.2479835265518212, 0.6335009955617831], ["Sharpness", 0.6260191862978083, 0.18998095149428562]], [["Invert", 0.9818841924943431, 0.03252098144087934], ["TranslateY", 0.9740718042586802, 0.32038951753031475]], [["Solarize", 0.8795784664090814, 0.7014953994354041], ["AutoContrast", 0.8508018319577783, 0.09321935255338443]], [["Color", 0.8067046326105318, 0.13732893832354054], ["Contrast", 0.7358549680271418, 0.7880588355974301]], [["Posterize", 0.5005885536838065, 0.7152229305267599], ["ShearX", 0.6714249591308944, 0.7732232697859908]], [["TranslateY", 0.5657943483353953, 0.04622399873706862], ["AutoContrast", 0.2787442688649845, 0.567024378767143]], [["ShearY", 0.7589839214283295, 0.041071003934029404], ["Equalize", 0.3719852873722692, 0.43285778682687326]], [["Posterize", 0.8841266183653291, 0.42441306955476366], ["Cutout", 0.06578801759412933, 0.5961125797961526]], [["Rotate", 0.4057875004314082, 0.20241115848366442], ["AutoContrast", 0.19331542807918067, 0.7175484678480565]], [["Contrast", 0.20331327116693088, 0.17135387852218742], ["Cutout", 0.6282459410351067, 0.6690015305529187]], [["ShearX", 0.4309850328306535, 0.99321178125828], ["AutoContrast", 0.01809604030453338, 0.693838277506365]], [["Rotate", 0.24343531125298268, 0.5326412444169899], ["Sharpness", 0.8663989992597494, 0.7643990609130789]], [["Rotate", 0.9785019204622459, 0.8941922576710696], ["ShearY", 0.3823185048761075, 0.9258854046017292]], [["ShearY", 0.5502613342963388, 0.6193478797355644], ["Sharpness", 0.2212116534610532, 0.6648232390110979]], [["TranslateY", 0.43222920981513757, 0.5657636397633089], ["ShearY", 0.9153733286073634, 0.4868521171273169]], [["Posterize", 0.12246560519738336, 0.9132288825898972], ["Cutout", 0.6058471327881816, 0.6426901876150983]], [["Color", 0.3693970222695844, 0.038929141432555436], ["Equalize", 0.6228052875653781, 0.05064436511347281]], [["Color", 0.7172600331356893, 0.2824542634766688], ["Color", 0.425293116261649, 0.1796441283313972]], [["Cutout", 0.7539608428122959, 0.9896141728228921], ["Solarize", 0.17811081117364758, 0.9064195503634402]], [["AutoContrast", 0.6761242607012717, 0.6484842446399923], ["AutoContrast", 0.1978135076901828, 0.42166879492601317]], [["ShearY", 0.25901666379802524, 0.4770778270322449], ["Solarize", 0.7640963173407052, 0.7548463227094349]], [["TranslateY", 0.9222487731783499, 0.33658389819616463], ["Equalize", 0.9159112511468139, 0.8877136302394797]], [["TranslateX", 0.8994836977137054, 0.11036053676846591], ["Sharpness", 0.9040333410652747, 0.007266095214664592]], [["Invert", 0.627758632524958, 0.8075245097227242], ["Color", 0.7525387912148516, 0.05950239294733184]], [["TranslateX", 0.43505193292761857, 0.38108822876120796], ["TranslateY", 0.7432578052364004, 0.685678116134759]], [["Contrast", 0.9293507582470425, 0.052266842951356196], ["Posterize", 0.45187123977747456, 0.8228290399726782]], [["ShearX", 0.07240786542746291, 0.8945667925365756], ["Brightness", 0.5305443506561034, 0.12025274552427578]], [["Invert", 0.40157564448143335, 0.5364745514006678], ["Posterize", 0.3316124671813876, 0.43002413237035997]], [["ShearY", 0.7152314630009072, 0.1938339083417453], ["Invert", 0.14102478508140615, 0.41047623580174253]], [["Equalize", 0.19862832613849246, 0.5058521685279254], ["Sharpness", 0.16481208629549782, 0.29126323102770557]], [["Equalize", 0.6951591703541872, 0.7294822018800076], ["ShearX", 0.8726656726111219, 0.3151484225786487]], [["Rotate", 0.17234370554263745, 0.9356543193000078], ["TranslateX", 0.4954374070084091, 0.05496727345849217]], [["Contrast", 0.347405480122842, 0.831553005022885], ["ShearX", 0.28946367213071134, 0.11905898704394013]], [["Rotate", 0.28096672507990683, 0.16181284050307398], ["Color", 0.6554918515385365, 0.8739728050797386]], [["Solarize", 0.05408073374114053, 0.5357087283758337], ["Posterize", 0.42457175211495335, 0.051807130609045515]], [["TranslateY", 0.6216669362331361, 0.9691341207381867], ["Rotate", 0.9833579358130944, 0.12227426932415297]], [["AutoContrast", 0.7572619475282892, 0.8062834082727393], ["Contrast", 0.1447865402875591, 0.40242646573228436]], [["Rotate", 0.7035658783466086, 0.9840285268256428], ["Contrast", 0.04613961510519471, 0.7666683217450163]], [["TranslateX", 0.4580462177951252, 0.6448678609474686], ["AutoContrast", 0.14845695613708987, 0.1581134188537895]], [["Color", 0.06795037145259564, 0.9115552821158709], ["TranslateY", 0.9972953449677655, 0.6791016521791214]], [["Cutout", 0.3586908443690823, 0.11578558293480945], ["Color", 0.49083981719164294, 0.6924851425917189]], [["Brightness", 0.7994717831637873, 0.7887316255321768], ["Posterize", 0.01280463502435425, 0.2799086732858721]], [["ShearY", 0.6733451536131859, 0.8122332639516706], ["AutoContrast", 0.20433889615637357, 0.29023346867819966]], [["TranslateY", 0.709913512385177, 0.6538196931503809], ["Invert", 0.06629795606579203, 0.40913219547548296]], [["Sharpness", 0.4704559834362948, 0.4235993305308414], ["Equalize", 0.7578132044306966, 0.9388824249397175]], [["AutoContrast", 0.5281702802395268, 0.8077253610116979], ["Equalize", 0.856446858814119, 0.0479755681647559]], [["Color", 0.8244145826797791, 0.038409264586238945], ["Equalize", 0.4933123249234237, 0.8251940933672189]], [["TranslateX", 0.23949314158035084, 0.13576027004706692], ["ShearX", 0.8547563771688399, 0.8309262160483606]], [["Cutout", 0.4655680937486001, 0.2819807000622825], ["Contrast", 0.8439552665937905, 0.4843617871587037]], [["TranslateX", 0.19142454476784831, 0.7516148119169537], ["AutoContrast", 0.8677128351329768, 0.34967990912346336]], [["Contrast", 0.2997868299880966, 0.919508054854469], ["AutoContrast", 0.3003418493384957, 0.812314984368542]], [["Invert", 0.1070424236198183, 0.614674386498809], ["TranslateX", 0.5010973510899923, 0.20828478805259465]], [["Contrast", 0.6775882415611454, 0.6938564815591685], ["Cutout", 0.4814634264207498, 0.3086844939744179]], [["TranslateY", 0.939427105020265, 0.02531043619423201], ["Contrast", 0.793754257944812, 0.6676072472565451]], [["Sharpness", 0.09833672397575444, 0.5937214638292085], ["Rotate", 0.32530675291753763, 0.08302275740932441]], [["Sharpness", 0.3096455511562728, 0.6726732004553959], ["TranslateY", 0.43268997648796537, 0.8755012330217743]], [["ShearY", 0.9290771880324833, 0.22114736271319912], ["Equalize", 0.5520199288501478, 0.34269650332060553]], [["AutoContrast", 0.39763980746649374, 0.4597414582725454], ["Contrast", 0.941507852412761, 0.24991270562477041]], [["Contrast", 0.19419400547588095, 0.9127524785329233], ["Invert", 0.40544905179551727, 0.770081532844878]], [["Invert", 0.30473757368608334, 0.23534811781828846], ["Cutout", 0.26090722356706686, 0.5478390909877727]], [["Posterize", 0.49434361308057373, 0.05018423270527428], ["Color", 0.3041910676883317, 0.2603810415446437]], [["Invert", 0.5149061746764011, 0.9507449210221298], ["TranslateY", 0.4458076521892904, 0.8235358255774426]], [["Cutout", 0.7900006753351625, 0.905578861382507], ["Cutout", 0.6707153655762056, 0.8236715672258502]], [["Solarize", 0.8750534386579575, 0.10337670467100568], ["Posterize", 0.6102379615481381, 0.9264503915416868]], [["ShearY", 0.08448689377082852, 0.13981233725811626], ["TranslateX", 0.13979689669329498, 0.768774869872818]], [["TranslateY", 0.35752572266759985, 0.22827299847812488], ["Solarize", 0.3906957174236011, 0.5663314388307709]], [["ShearY", 0.29155240367061563, 0.8427516352971683], ["ShearX", 0.988825367441916, 0.9371258864857649]], [["Posterize", 0.3470780859769458, 0.5467686612321239], ["Rotate", 0.5758606274160093, 0.8843838082656007]], [["Cutout", 0.07825368363221841, 0.3230799425855425], ["Equalize", 0.2319163865298529, 0.42133965674727325]], [["Invert", 0.41972172597448654, 0.34618622513582953], ["ShearX", 0.33638469398198834, 0.9098575535928108]], [["Invert", 0.7322652233340448, 0.7747502957687412], ["Cutout", 0.9643121397298106, 0.7983335094634907]], [["TranslateY", 0.30039942808098496, 0.229018798182827], ["TranslateY", 0.27009499739380194, 0.6435577237846236]], [["Color", 0.38245274994070644, 0.7030758568461645], ["ShearX", 0.4429321461666281, 0.6963787864044149]], [["AutoContrast", 0.8432798685515605, 0.5775214369578088], ["Brightness", 0.7140899735355927, 0.8545854720117658]], [["Rotate", 0.14418935535613786, 0.5637968282213426], ["Color", 0.7115231912479835, 0.32584796564566776]], [["Sharpness", 0.4023501062807533, 0.4162097130412771], ["Brightness", 0.5536372686153666, 0.03004023273348777]], [["TranslateX", 0.7526053265574295, 0.5365938133399961], ["Cutout", 0.07914142706557492, 0.7544953091603148]], [["TranslateY", 0.6932934644882822, 0.5302211727137424], ["Invert", 0.5040606028391255, 0.6074863635108957]], [["Sharpness", 0.5013938602431629, 0.9572417724333157], ["TranslateY", 0.9160516359783026, 0.41798927975391675]], [["ShearY", 0.5130018836722556, 0.30209438428424185], ["Color", 0.15017170588500262, 0.20653495360587826]], [["TranslateX", 0.5293300090022314, 0.6407011888285266], ["Rotate", 0.4809817860439001, 0.3537850070371702]], [["Equalize", 0.42243081336551014, 0.13472721311046565], ["Posterize", 0.4700309639484068, 0.5197704360874883]], [["AutoContrast", 0.40674959899687235, 0.7312824868168921], ["TranslateX", 0.7397527975920833, 0.7068339877944815]], [["TranslateY", 0.5880995184787206, 0.41294111378078946], ["ShearX", 0.3181387627799316, 0.4810010147143413]], [["Color", 0.9898680233928507, 0.13241525577655167], ["Contrast", 0.9824932511238534, 0.5081145010853807]], [["Invert", 0.1591854062582687, 0.9760371953250404], ["Color", 0.9913399302056851, 0.8388709501056177]], [["Rotate", 0.6427451962231163, 0.9486793975292853], ["AutoContrast", 0.8501937877930463, 0.021326757974406196]], [["Contrast", 0.13611684531087598, 0.3050858709483848], ["Posterize", 0.06618644756084646, 0.8776928511951034]], [["TranslateX", 0.41021065663839407, 0.4965319749091702], ["Rotate", 0.07088831484595115, 0.4435516708223345]], [["Sharpness", 0.3151707977154323, 0.28275482520179296], ["Invert", 0.36980384682133804, 0.20813616084536624]], [["Cutout", 0.9979060206661017, 0.39712948644725854], ["Brightness", 0.42451052896163466, 0.942623075649937]], [["Equalize", 0.5300853308425644, 0.010183500830128867], ["AutoContrast", 0.06930788523716991, 0.5403125318991522]], [["Contrast", 0.010385458959237814, 0.2588311035539086], ["ShearY", 0.9347048553928764, 0.10439028366854963]], [["ShearY", 0.9867649486508592, 0.8409258132716434], ["ShearX", 0.48031199530836444, 0.7703375364614137]], [["ShearY", 0.04835889473136512, 0.2671081675890492], ["Brightness", 0.7856432618509617, 0.8032169570159564]], [["Posterize", 0.11112884927351185, 0.7116956530752987], ["TranslateY", 0.7339151092128607, 0.3331241226029017]], [["Invert", 0.13527036207875454, 0.8425980515358883], ["Color", 0.7836395778298139, 0.5517059252678862]], [["Sharpness", 0.012541163521491816, 0.013197550692292892], ["Invert", 0.6295957932861318, 0.43276521236056054]], [["AutoContrast", 0.7681480991225756, 0.3634284648496289], ["Brightness", 0.09708289828517969, 0.45016725043529726]], [["Brightness", 0.5839450499487329, 0.47525965678316795], ["Posterize", 0.43096581990183735, 0.9332382960125196]], [["Contrast", 0.9725334964552795, 0.9142902966863341], ["Contrast", 0.12376116410622995, 0.4355916974126801]], [["TranslateX", 0.8572708473690132, 0.02544522678265526], ["Sharpness", 0.37902120723460364, 0.9606092969833118]], [["TranslateY", 0.8907359001296927, 0.8011363927236099], ["Color", 0.7693777154407178, 0.0936768686746503]], [["Equalize", 0.0002657688243309364, 0.08190798535970034], ["Rotate", 0.5215478065240905, 0.5773519995038368]], [["TranslateY", 0.3383007813932477, 0.5733428274739165], ["Sharpness", 0.2436110797174722, 0.4757790814590501]], [["Cutout", 0.0957402176213592, 0.8914395928996034], ["Cutout", 0.4959915628586883, 0.25890349461645246]], [["AutoContrast", 0.594787300189186, 0.9627455357634459], ["ShearY", 0.5136027621132064, 0.10419602450259002]], [["Solarize", 0.4684077211553732, 0.6592850629431414], ["Sharpness", 0.2382385935956325, 0.6589291408243176]], [["Cutout", 0.4478786947325877, 0.6893616643143388], ["TranslateX", 0.2761781720270474, 0.21750622627277727]], [["Sharpness", 0.39476077929016484, 0.930902796668923], ["Cutout", 0.9073012208742808, 0.9881122386614257]], [["TranslateY", 0.0933719180021565, 0.7206252503441172], ["ShearX", 0.5151400441789256, 0.6307540083648309]], [["AutoContrast", 0.7772689258806401, 0.8159317013156503], ["AutoContrast", 0.5932793713915097, 0.05262217353927168]], [["Equalize", 0.38017352056118914, 0.8084724050448412], ["ShearY", 0.7239725628380852, 0.4246314890359326]], [["Cutout", 0.741157483503503, 0.13244380646497977], ["Invert", 0.03395378056675935, 0.7140036618098844]], [["Rotate", 0.0662727247460636, 0.7099861732415447], ["Rotate", 0.3168532707508249, 0.3553167425022127]], [["AutoContrast", 0.7429303516734129, 0.07117444599776435], ["Posterize", 0.5379537435918104, 0.807221330263993]], [["TranslateY", 0.9788586874795164, 0.7967243851346594], ["Invert", 0.4479103376922362, 0.04260360776727545]], [["Cutout", 0.28318121763188997, 0.7748680701406292], ["AutoContrast", 0.9109258369403016, 0.17126397858002085]], [["Color", 0.30183727885272027, 0.46718354750112456], ["TranslateX", 0.9628952256033627, 0.10269543754135535]], [["AutoContrast", 0.6316709389784041, 0.84287698792044], ["Brightness", 0.5544761629904337, 0.025264772745200004]], [["Rotate", 0.08803313299532567, 0.306059720523696], ["Invert", 0.5222165872425064, 0.045935208620454304]], [["TranslateY", 0.21912346831923835, 0.48529224559004436], ["TranslateY", 0.15466734731903942, 0.8929485418495068]], [["ShearX", 0.17141022847016563, 0.8607600402165531], ["ShearX", 0.6890511341106859, 0.7540899265679949]], [["Invert", 0.9417455522972059, 0.9021733684991224], ["Solarize", 0.7693107057723746, 0.7268007946568782]], [["Posterize", 0.02376991543373752, 0.6768442864453844], ["Rotate", 0.7736875065112697, 0.6706331753139825]], [["Contrast", 0.3623841610390669, 0.15023657344457686], ["Equalize", 0.32975472189318666, 0.05629246869510651]], [["Sharpness", 0.7874882420165824, 0.49535778020457066], ["Posterize", 0.09485578893387558, 0.6170768580482466]], [["Brightness", 0.7099280202949585, 0.021523012961427335], ["Posterize", 0.2076371467666719, 0.17168118578815206]], [["Color", 0.8546367645761538, 0.832011891505731], ["Equalize", 0.6429734783051777, 0.2618995960561532]], [["Rotate", 0.8780793721476224, 0.5920897827664297], ["ShearX", 0.5338303685064825, 0.8605424531336439]], [["Sharpness", 0.7504493806631884, 0.9723552387375258], ["Sharpness", 0.3206385634203266, 0.45127845905824693]], [["ShearX", 0.23794709526711355, 0.06257530645720066], ["Solarize", 0.9132374030587093, 0.6240819934824045]], [["Sharpness", 0.790583587969259, 0.28551171786655405], ["Contrast", 0.39872982844590554, 0.09644706751019538]], [["Equalize", 0.30681999237432944, 0.5645045018157916], ["Posterize", 0.525966242669736, 0.7360106111256014]], [["TranslateX", 0.4881014179825114, 0.6317220208872226], ["ShearX", 0.2935158995550958, 0.23104608987381758]], [["Rotate", 0.49977116738568395, 0.6610761068306319], ["TranslateY", 0.7396566602715687, 0.09386747830045217]], [["ShearY", 0.5909773790018789, 0.16229529902832718], ["Equalize", 0.06461394468918358, 0.6661349001143908]], [["TranslateX", 0.7218443721851834, 0.04435720302810153], ["Cutout", 0.986686540951642, 0.734771197038724]], [["ShearX", 0.5353800096911666, 0.8120139502148365], ["Equalize", 0.4613239578449774, 0.5159528929124512]], [["Color", 0.0871713897628631, 0.7708895183198486], ["Solarize", 0.5811386808912219, 0.35260648120785887]], [["Posterize", 0.3910857927477053, 0.4329219555775561], ["Color", 0.9115983668789468, 0.6043069944145293]], [["Posterize", 0.07493067637060635, 0.4258000066006725], ["AutoContrast", 0.4740957581389772, 0.49069587151651295]], [["Rotate", 0.34086200894268937, 0.9812149332288828], ["Solarize", 0.6801012471371733, 0.17271491146753837]], [["Color", 0.20542270872895207, 0.5532087457727624], ["Contrast", 0.2718692536563381, 0.20313287569510108]], [["Equalize", 0.05199827210980934, 0.0832859890912212], ["AutoContrast", 0.8092395764794107, 0.7778945136511004]], [["Sharpness", 0.1907689513066838, 0.7705754572256907], ["Color", 0.3911178658498049, 0.41791326933095485]], [["Solarize", 0.19611855804748257, 0.2407807485604081], ["AutoContrast", 0.5343964972940493, 0.9034209455548394]], [["Color", 0.43586520148538865, 0.4711164626521439], ["ShearY", 0.28635408186820555, 0.8417816793020271]], [["Cutout", 0.09818482420382535, 0.1649767430954796], ["Cutout", 0.34582392911178494, 0.3927982995799828]], [["ShearX", 0.001253882705272269, 0.48661629027584596], ["Solarize", 0.9229221435457137, 0.44374894836659073]], [["Contrast", 0.6829734655718668, 0.8201750485099037], ["Cutout", 0.7886756837648936, 0.8423285219631946]], [["TranslateY", 0.857017093561528, 0.3038537151773969], ["Invert", 0.12809228606383538, 0.23637166191748027]], [["Solarize", 0.9829027723424164, 0.9723093910674763], ["Color", 0.6346495302126811, 0.5405494753107188]], [["AutoContrast", 0.06868643520377715, 0.23758659417688077], ["AutoContrast", 0.6648225411500879, 0.5618315648260103]], [["Invert", 0.44202305603311676, 0.9945938909685547], ["Equalize", 0.7991650497684454, 0.16014142656347097]], [["AutoContrast", 0.8778631604769588, 0.03951977631894088], ["ShearY", 0.8495160088963707, 0.35771447321250416]], [["Color", 0.5365078341001592, 0.21102444169782308], ["ShearX", 0.7168869678248874, 0.3904298719872734]], [["TranslateX", 0.6517203786101899, 0.6467598990650437], ["Invert", 0.26552491504364517, 0.1210812827294625]], [["Posterize", 0.35196021684368994, 0.8420648319941891], ["Invert", 0.7796829363930631, 0.9520895999240896]], [["Sharpness", 0.7391572148971984, 0.4853940393452846], ["TranslateX", 0.7641915295592839, 0.6351349057666782]], [["Posterize", 0.18485880221115913, 0.6117603277356728], ["Rotate", 0.6541660490605724, 0.5704041108375348]], [["TranslateY", 0.27517423188070533, 0.6610080904072458], ["Contrast", 0.6091250547289317, 0.7702443247557892]], [["Equalize", 0.3611798581067118, 0.6623615672642768], ["TranslateX", 0.9537265090885917, 0.06352772509358584]], [["ShearX", 0.09720029389103535, 0.7800423126320308], ["Invert", 0.30314352455858884, 0.8519925470889914]], [["Brightness", 0.06931529763458055, 0.57760829499712], ["Cutout", 0.637251974467394, 0.7184346129191052]], [["AutoContrast", 0.5026722100286064, 0.32025257156541886], ["Contrast", 0.9667478703047919, 0.14178519432669368]], [["Equalize", 0.5924463845816984, 0.7187610262181517], ["TranslateY", 0.7059479079159405, 0.06551471830655187]], [["Sharpness", 0.18161164512332928, 0.7576138481173385], ["Brightness", 0.19191138767695282, 0.7865880269424701]], [["Brightness", 0.36780861866078696, 0.0677855546737901], ["AutoContrast", 0.8491446654142264, 0.09217782099938121]], [["TranslateY", 0.06011399855120858, 0.8374487034710264], ["TranslateY", 0.8373922962070498, 0.1991295720254297]], [["Posterize", 0.702559916122481, 0.30257509683007755], ["Rotate", 0.249899495398891, 0.9370437251176267]], [["ShearX", 0.9237874098232075, 0.26241907483351146], ["Brightness", 0.7221766836146657, 0.6880749752986671]], [["Cutout", 0.37994098189193104, 0.7836874473657957], ["ShearX", 0.9212861960976824, 0.8140948561570449]], [["Posterize", 0.2584098274786417, 0.7990847652004848], ["Invert", 0.6357731737590063, 0.1066304859116326]], [["Sharpness", 0.4412790857539922, 0.9692465283229825], ["Color", 0.9857401617339051, 0.26755393929808713]], [["Equalize", 0.22348671644912665, 0.7370019910830038], ["Posterize", 0.5396106339575417, 0.5559536849843303]], [["Equalize", 0.8742967663495852, 0.2797122599926307], ["Rotate", 0.4697322053105951, 0.8769872942579476]], [["Sharpness", 0.44279911640509206, 0.07729581896071613], ["Cutout", 0.3589177366154631, 0.2704031551235969]], [["TranslateX", 0.614216412574085, 0.47929659784170453], ["Brightness", 0.6686234118438007, 0.05700784068205689]], [["ShearY", 0.17920614630857634, 0.4699685075827862], ["Color", 0.38251870810870003, 0.7262706923005887]], [["Solarize", 0.4951799001144561, 0.212775278026479], ["TranslateX", 0.8666105646463097, 0.6750496637519537]], [["Color", 0.8110864170849051, 0.5154263861958484], ["Sharpness", 0.2489044083898776, 0.3763372541462343]], [["Cutout", 0.04888193613483871, 0.06041664638981603], ["Color", 0.06438587718683708, 0.5797881428892969]], [["Rotate", 0.032427448352152166, 0.4445797818376559], ["Posterize", 0.4459357828482998, 0.5879865187630777]], [["ShearX", 0.1617179557693058, 0.050796802246318884], ["Cutout", 0.8142465452060423, 0.3836391305618707]], [["TranslateY", 0.1806857249209416, 0.36697730355422675], ["Rotate", 0.9897576550818276, 0.7483432452225264]], [["Brightness", 0.18278016458098223, 0.952352527690299], ["Cutout", 0.3269735224453044, 0.3924869905012752]], [["ShearX", 0.870832707718742, 0.3214743207190739], ["Cutout", 0.6805560681792573, 0.6984188155282459]], [["TranslateX", 0.4157118388833776, 0.3964216288135384], ["TranslateX", 0.3253012682285006, 0.624835513104391]], [["Contrast", 0.7678168037628158, 0.31033802162621793], ["ShearX", 0.27022424855977134, 0.3773245605126201]], [["TranslateX", 0.37812621869017593, 0.7657993810740699], ["Rotate", 0.18081890120092914, 0.8893511219618171]], [["Posterize", 0.8735859716088367, 0.18243793043074286], ["TranslateX", 0.90435994250313, 0.24116383818819453]], [["Invert", 0.06666709253664793, 0.3881076083593933], ["TranslateX", 0.3783333964963522, 0.14411014979589543]], [["Equalize", 0.8741147867162096, 0.14203839235846816], ["TranslateX", 0.7801536758037405, 0.6952401607812743]], [["Cutout", 0.6095335117944475, 0.5679026063718094], ["Posterize", 0.06433868172233115, 0.07139559616012303]], [["TranslateY", 0.3020364047315408, 0.21459810361176246], ["Cutout", 0.7097677414888889, 0.2942144632587549]], [["Brightness", 0.8223662419048653, 0.195700694016108], ["Invert", 0.09345407040803999, 0.779843655582099]], [["TranslateY", 0.7353462929356228, 0.0468520680237382], ["Cutout", 0.36530918247940425, 0.3897292909049672]], [["Invert", 0.9676896451721213, 0.24473302189463453], ["Invert", 0.7369271521408992, 0.8193267003356975]], [["Sharpness", 0.8691871972054326, 0.4441713912682772], ["ShearY", 0.47385584832119887, 0.23521684584675429]], [["ShearY", 0.9266946026184021, 0.7611986713358834], ["TranslateX", 0.6195820760253926, 0.14661428669483678]], [["Sharpness", 0.08470870576026868, 0.3380219099907229], ["TranslateX", 0.3062343307496658, 0.7135777338095889]], [["Sharpness", 0.5246448204194909, 0.3193061215236702], ["ShearX", 0.8160637208508432, 0.9720697396582731]], [["Posterize", 0.5249259956549405, 0.3492042382504774], ["Invert", 0.8183138799547441, 0.11107271762524618]], [["TranslateY", 0.210869733350744, 0.7138905840721885], ["Sharpness", 0.7773226404450125, 0.8005353621959782]], [["Posterize", 0.33067522385556025, 0.32046239220630124], ["AutoContrast", 0.18918147708798405, 0.4646281070474484]], [["TranslateX", 0.929502026131094, 0.8029128121556285], ["Invert", 0.7319794306118105, 0.5421878712623392]], [["ShearX", 0.25645940834182723, 0.42754710760160963], ["ShearX", 0.44640695310173306, 0.8132185532296811]], [["Color", 0.018436846416536312, 0.8439313862001113], ["Sharpness", 0.3722867661453415, 0.5103570873163251]], [["TranslateX", 0.7285989086776543, 0.4809027697099264], ["TranslateY", 0.9740807004893643, 0.8241085438636939]], [["Posterize", 0.8721868989693397, 0.5700907310383815], ["Posterize", 0.4219074410577852, 0.8032643572845402]], [["Contrast", 0.9811380092558266, 0.8498397471632105], ["Sharpness", 0.8380884329421594, 0.18351306571903125]], [["TranslateY", 0.3878939366762001, 0.4699103438753077], ["Invert", 0.6055556353233807, 0.8774727658400134]], [["TranslateY", 0.052317005261018346, 0.39471450378745787], ["ShearX", 0.8612486845942395, 0.28834103278807466]], [["Color", 0.511993351208063, 0.07251427040525904], ["Solarize", 0.9898097047354855, 0.299761565689576]], [["Equalize", 0.2721248231619904, 0.6870975927455507], ["Cutout", 0.8787327242363994, 0.06228061428917098]], [["Invert", 0.8931880335225408, 0.49720931867378193], ["Posterize", 0.9619698792159256, 0.17859639696940088]], [["Posterize", 0.0061688075074411985, 0.08082938731035938], ["Brightness", 0.27745128028826993, 0.8638528796903816]], [["ShearY", 0.9140200609222026, 0.8240421430867707], ["Invert", 0.651734417415332, 0.08871906369930926]], [["Color", 0.45585010413511196, 0.44705070078574316], ["Color", 0.26394624901633146, 0.11242877788650807]], [["ShearY", 0.9200278466372522, 0.2995901331149652], ["Cutout", 0.8445407215116278, 0.7410524214287446]], [["ShearY", 0.9950483746990132, 0.112964468262847], ["ShearY", 0.4118332303218585, 0.44839613407553636]], [["Contrast", 0.7905821952255192, 0.23360046159385106], ["Posterize", 0.8611787233956044, 0.8984260048943528]], [["TranslateY", 0.21448061359312853, 0.8228112806838331], ["Contrast", 0.8992297266152983, 0.9179231590570998]], [["Invert", 0.3924194798946006, 0.31830516468371495], ["Rotate", 0.8399556845248508, 0.3764892022932781]], [["Cutout", 0.7037916990046816, 0.9214620769502728], ["AutoContrast", 0.02913794613018239, 0.07808607528954048]], [["ShearY", 0.6041490474263381, 0.6094184590800105], ["Equalize", 0.2932954517354919, 0.5840888946081727]], [["ShearX", 0.6056801676269449, 0.6948580442549543], ["Cutout", 0.3028001021044615, 0.15117101733894078]], [["Brightness", 0.8011486803860253, 0.18864079729374195], ["Solarize", 0.014965327213230961, 0.8842620292527029]], [["Invert", 0.902244007904273, 0.5634673798052033], ["Equalize", 0.13422913507398349, 0.4110956745883727]], [["TranslateY", 0.9981773319103838, 0.09568550987216096], ["Color", 0.7627662124105109, 0.8494409737419493]], [["Cutout", 0.3013527640416782, 0.03377226729898486], ["ShearX", 0.5727964831614619, 0.8784196638222834]], [["TranslateX", 0.6050722426803684, 0.3650103962378708], ["TranslateX", 0.8392084589130886, 0.6479816470292911]], [["Rotate", 0.5032806606500023, 0.09276980118866307], ["TranslateY", 0.7800234515261191, 0.18896454379343308]], [["Invert", 0.9266027256244017, 0.8246111062199752], ["Contrast", 0.12112023357797697, 0.33870762271759436]], [["Brightness", 0.8688784756993134, 0.17263759696106606], ["ShearX", 0.5133700431071326, 0.6686811994542494]], [["Invert", 0.8347840440941976, 0.03774897445901726], ["Brightness", 0.24925057499276548, 0.04293631677355758]], [["Color", 0.5998145279485104, 0.4820093200092529], ["TranslateY", 0.6709586184077769, 0.07377334081382858]], [["AutoContrast", 0.7898846202957984, 0.325293526672498], ["Contrast", 0.5156435596826767, 0.2889223168660645]], [["ShearX", 0.08147389674998307, 0.7978924681113669], ["Contrast", 0.7270003309106291, 0.009571215234092656]], [["Sharpness", 0.417607614440786, 0.9532566433338661], ["Posterize", 0.7186586546796782, 0.6936509907073302]], [["ShearX", 0.9555300215926675, 0.1399385550263872], ["Color", 0.9981041061848231, 0.5037462398323248]], [["Equalize", 0.8003487831375474, 0.5413759363796945], ["ShearY", 0.0026607045117773565, 0.019262273030984933]], [["TranslateY", 0.04845391502469176, 0.10063445212118283], ["Cutout", 0.8273170186786745, 0.5045257728554577]], [["TranslateX", 0.9690985344978033, 0.505202991815533], ["TranslateY", 0.7255326592928096, 0.02103609500701631]], [["Solarize", 0.4030771176836736, 0.8424237871457034], ["Cutout", 0.28705805963928965, 0.9601617893682582]], [["Sharpness", 0.16865290353070606, 0.6899673563468826], ["Posterize", 0.3985430034869616, 0.6540651997730774]], [["ShearY", 0.21395578485362032, 0.09519358818949009], ["Solarize", 0.6692821708524135, 0.6462523623552485]], [["AutoContrast", 0.912360598054091, 0.029800239085051583], ["Invert", 0.04319256403746308, 0.7712501517098587]], [["ShearY", 0.9081969961839055, 0.4581560239984739], ["AutoContrast", 0.5313894814729159, 0.5508393335751848]], [["ShearY", 0.860528568424097, 0.8196987216301588], ["Posterize", 0.41134650331494205, 0.3686632018978778]], [["AutoContrast", 0.8753670810078598, 0.3679438326304749], ["Invert", 0.010444228965415858, 0.9581244779208277]], [["Equalize", 0.07071836206680682, 0.7173594756186462], ["Brightness", 0.06111434312497388, 0.16175064669049277]], [["AutoContrast", 0.10522219073562122, 0.9768776621069855], ["TranslateY", 0.2744795945215529, 0.8577967957127298]], [["AutoContrast", 0.7628146493166175, 0.996157376418147], ["Contrast", 0.9255565598518469, 0.6826126662976868]], [["TranslateX", 0.017225816199011312, 0.2470332491402908], ["Solarize", 0.44048494909493807, 0.4492422515972162]], [["ShearY", 0.38885252627795064, 0.10272256704901939], ["Equalize", 0.686154959829183, 0.8973517148655337]], [["Rotate", 0.29628991573592967, 0.16639926575004715], ["ShearX", 0.9013782324726413, 0.0838318162771563]], [["Color", 0.04968391374688563, 0.6138600739645352], ["Invert", 0.11177127838716283, 0.10650198522261578]], [["Invert", 0.49655016367624016, 0.8603374164829688], ["ShearY", 0.40625439617553727, 0.4516437918820778]], [["TranslateX", 0.15015718916062992, 0.13867777502116208], ["Brightness", 0.3374464418810188, 0.7613355669536931]], [["Invert", 0.644644393321966, 0.19005804481199562], ["AutoContrast", 0.2293259789431853, 0.30335723256340186]], [["Solarize", 0.004968793254801596, 0.5370892072646645], ["Contrast", 0.9136902637865596, 0.9510587477779084]], [["Rotate", 0.38991518440867123, 0.24796987467455756], ["Sharpness", 0.9911180315669776, 0.5265657122981591]], [["Solarize", 0.3919646484436238, 0.6814994037194909], ["Sharpness", 0.4920838987787103, 0.023425724294012018]], [["TranslateX", 0.25107587874378867, 0.5414936560189212], ["Cutout", 0.7932919623814599, 0.9891303444820169]], [["Brightness", 0.07863012174272999, 0.045175652208389594], ["Solarize", 0.889609658064552, 0.8228793315963948]], [["Cutout", 0.20477096178169596, 0.6535063675027364], ["ShearX", 0.9216318577173639, 0.2908690977359947]], [["Contrast", 0.7035118947423187, 0.45982709058312454], ["Contrast", 0.7130268070749464, 0.8635123354235471]], [["Sharpness", 0.26319477541228997, 0.7451278726847078], ["Rotate", 0.8170499362173754, 0.13998593411788207]], [["Rotate", 0.8699365715164192, 0.8878057721750832], ["Equalize", 0.06682350555715044, 0.7164702080630689]], [["ShearY", 0.3137466057521987, 0.6747433496011368], ["Rotate", 0.42118828936218133, 0.980121180104441]], [["Solarize", 0.8470375049950615, 0.15287589264139223], ["Cutout", 0.14438435054693055, 0.24296463267973512]], [["TranslateY", 0.08822241792224905, 0.36163911974799356], ["TranslateY", 0.11729726813270003, 0.6230889726445291]], [["ShearX", 0.7720112337718541, 0.2773292905760122], ["Sharpness", 0.756290929398613, 0.27830353710507705]], [["Color", 0.33825031007968287, 0.4657590047522816], ["ShearY", 0.3566628994713067, 0.859750504071925]], [["TranslateY", 0.06830147433378053, 0.9348778582086664], ["TranslateX", 0.15509346516378553, 0.26320778885339435]], [["Posterize", 0.20266751150740858, 0.008351463842578233], ["Sharpness", 0.06506971109417259, 0.7294471760284555]], [["TranslateY", 0.6278911394418829, 0.8702181892620695], ["Invert", 0.9367073860264247, 0.9219230428944211]], [["Sharpness", 0.1553425337673321, 0.17601557714491345], ["Solarize", 0.7040449681338888, 0.08764313147327729]], [["Equalize", 0.6082233904624664, 0.4177428549911376], ["AutoContrast", 0.04987405274618151, 0.34516208204700916]], [["Brightness", 0.9616085936167699, 0.14561237331885468], ["Solarize", 0.8927707736296572, 0.31176907850205704]], [["Brightness", 0.6707778304730988, 0.9046457117525516], ["Brightness", 0.6801448953060988, 0.20015313057149042]], [["Color", 0.8292680845499386, 0.5181603879593888], ["Brightness", 0.08549161770369762, 0.6567870536463203]], [["ShearY", 0.267802208078051, 0.8388133819588173], ["Sharpness", 0.13453409120796123, 0.10028351311149486]], [["Posterize", 0.775796593610272, 0.05359034561289766], ["Cutout", 0.5067360625733027, 0.054451986840317934]], [["TranslateX", 0.5845238647690084, 0.7507147553486293], ["Brightness", 0.2642051786121197, 0.2578358927056452]], [["Cutout", 0.10787517610922692, 0.8147986902794228], ["Contrast", 0.2190149206329539, 0.902210615462459]], [["TranslateX", 0.5663614214181296, 0.05309965916414028], ["ShearX", 0.9682797885154938, 0.41791929533938466]], [["ShearX", 0.2345325577621098, 0.383780128037189], ["TranslateX", 0.7298083748149163, 0.644325797667087]], [["Posterize", 0.5138725709682734, 0.7901809917259563], ["AutoContrast", 0.7966018627776853, 0.14529337543427345]], [["Invert", 0.5973031989249785, 0.417399314592829], ["Solarize", 0.9147539948653116, 0.8221272315548086]], [["Posterize", 0.601596043336383, 0.18969646160963938], ["Color", 0.7527275484079655, 0.431793831326888]], [["Equalize", 0.6731483454430538, 0.7866786558207602], ["TranslateX", 0.97574396899191, 0.5970255778044692]], [["Cutout", 0.15919495850169718, 0.8916094305850562], ["Invert", 0.8351348834751027, 0.4029937360314928]], [["Invert", 0.5894085405226027, 0.7283806854157764], ["Brightness", 0.3973976860470554, 0.949681121498567]], [["AutoContrast", 0.3707914135327408, 0.21192068592079616], ["ShearX", 0.28040127351140676, 0.6754553511344856]], [["Solarize", 0.07955132378694896, 0.15073572961927306], ["ShearY", 0.5735850168851625, 0.27147326850217746]], [["Equalize", 0.678653949549764, 0.8097796067861455], ["Contrast", 0.2283048527510083, 0.15507804874474185]], [["Equalize", 0.286013868374536, 0.186785848694501], ["Posterize", 0.16319021740810458, 0.1201304443285659]], [["Sharpness", 0.9601590830563757, 0.06267915026513238], ["AutoContrast", 0.3813920685124327, 0.294224403296912]], [["Brightness", 0.2703246632402241, 0.9168405377492277], ["ShearX", 0.6156009855831097, 0.4955986055846403]], [["Color", 0.9065504424987322, 0.03393612216080133], ["ShearY", 0.6768595880405884, 0.9981068127818191]], [["Equalize", 0.28812842368483904, 0.300387487349145], ["ShearY", 0.28812248704858345, 0.27105076231533964]], [["Brightness", 0.6864882730513477, 0.8205553299102412], ["Cutout", 0.45995236371265424, 0.5422030370297759]], [["Color", 0.34941404877084326, 0.25857961830158516], ["AutoContrast", 0.3451390878441899, 0.5000938249040454]], [["Invert", 0.8268247541815854, 0.6691380821226468], ["Cutout", 0.46489193601530476, 0.22620873109485895]], [["Rotate", 0.17879730528062376, 0.22670425330593935], ["Sharpness", 0.8692795688221834, 0.36586055020855723]], [["Brightness", 0.31203975139659634, 0.6934046293010939], ["Cutout", 0.31649437872271236, 0.08078625004157935]], [["Cutout", 0.3119482836150119, 0.6397160035509996], ["Contrast", 0.8311248624784223, 0.22897510169718616]], [["TranslateX", 0.7631157841429582, 0.6482890521284557], ["Brightness", 0.12681196272427664, 0.3669813784257344]], [["TranslateX", 0.06027722649179801, 0.3101104512201861], ["Sharpness", 0.5652076706249394, 0.05210008400968136]], [["AutoContrast", 0.39213552101583127, 0.5047021194355596], ["ShearY", 0.7164003055682187, 0.8063370761002899]], [["Solarize", 0.9574307011238342, 0.21472064809226854], ["AutoContrast", 0.8102612285047174, 0.716870148067014]], [["Rotate", 0.3592634277567387, 0.6452602893051465], ["AutoContrast", 0.27188430331411506, 0.06003099168464854]], [["Cutout", 0.9529536554825503, 0.5285505311027461], ["Solarize", 0.08478231903311029, 0.15986449762728216]], [["TranslateY", 0.31176130458018936, 0.5642853506158253], ["Equalize", 0.008890883901317648, 0.5146121040955942]], [["Color", 0.40773645085566157, 0.7110398926612682], ["Color", 0.18233100156439364, 0.7830036002758337]], [["Posterize", 0.5793809197821732, 0.043748553135581236], ["Invert", 0.4479962016131668, 0.7349663010359488]], [["TranslateX", 0.1994882312299382, 0.05216859488899439], ["Rotate", 0.48288726352035416, 0.44713829026777585]], [["Posterize", 0.22122838185154603, 0.5034546841241283], ["TranslateX", 0.2538745835410222, 0.6129055170893385]], [["Color", 0.6786559960640814, 0.4529749369803212], ["Equalize", 0.30215879674415336, 0.8733394611096772]], [["Contrast", 0.47316062430673456, 0.46669538897311447], ["Invert", 0.6514906551984854, 0.3053339444067804]], [["Equalize", 0.6443202625334524, 0.8689731394616441], ["Color", 0.7549183794057628, 0.8889001426329578]], [["Solarize", 0.616709740662654, 0.7792180816399313], ["ShearX", 0.9659155537406062, 0.39436937531179495]], [["Equalize", 0.23694011299406226, 0.027711152164392128], ["TranslateY", 0.1677339686527083, 0.3482126536808231]], [["Solarize", 0.15234175951790285, 0.7893840414281341], ["TranslateX", 0.2396395768284183, 0.27727219214979715]], [["Contrast", 0.3792017455380605, 0.32323660409845334], ["Contrast", 0.1356037413846466, 0.9127772969992305]], [["ShearX", 0.02642732222284716, 0.9184662576502115], ["Equalize", 0.11504884472142995, 0.8957638893097964]], [["TranslateY", 0.3193812913345325, 0.8828100030493128], ["ShearY", 0.9374975727563528, 0.09909415611083694]], [["AutoContrast", 0.025840721736048122, 0.7941037581373024], ["TranslateY", 0.498518003323313, 0.5777122846572548]], [["ShearY", 0.6042199307830248, 0.44809668754508836], ["Cutout", 0.3243978207701482, 0.9379740926294765]], [["ShearY", 0.6858549297583574, 0.9993252035788924], ["Sharpness", 0.04682428732773203, 0.21698099707915652]], [["ShearY", 0.7737469436637263, 0.8810127181224531], ["ShearY", 0.8995655445246451, 0.4312416220354539]], [["TranslateY", 0.4953094136709374, 0.8144161580138571], ["Solarize", 0.26301211718928097, 0.518345311180405]], [["Brightness", 0.8820246486031275, 0.571075863786249], ["ShearX", 0.8586669146703955, 0.0060476383595142735]], [["Sharpness", 0.20519233710982254, 0.6144574759149729], ["Posterize", 0.07976625267460813, 0.7480145046726968]], [["ShearY", 0.374075419680195, 0.3386105402023202], ["ShearX", 0.8228083637082115, 0.5885174783155361]], [["Brightness", 0.3528780713814561, 0.6999884884306623], ["Sharpness", 0.3680348120526238, 0.16953358258959617]], [["Brightness", 0.24891223104442084, 0.7973853494920095], ["TranslateX", 0.004256803835524736, 0.0470216343108546]], [["Posterize", 0.1947344282646012, 0.7694802711054367], ["Cutout", 0.9594385534844785, 0.5469744140592429]], [["Invert", 0.19012504762806026, 0.7816140211434693], ["TranslateY", 0.17479746932338402, 0.024249345245078602]], [["Rotate", 0.9669262055946796, 0.510166180775991], ["TranslateX", 0.8990602034610352, 0.6657802719304693]], [["ShearY", 0.5453049050407278, 0.8476872739603525], ["Cutout", 0.14226529093962592, 0.15756960661106634]], [["Equalize", 0.5895291156113004, 0.6797218994447763], ["TranslateY", 0.3541442192192753, 0.05166001155849864]], [["Equalize", 0.39530681662726097, 0.8448335365081087], ["Brightness", 0.6785483272734143, 0.8805568647038574]], [["Cutout", 0.28633258271917905, 0.7750870268336066], ["Equalize", 0.7221097824537182, 0.5865506280531162]], [["Posterize", 0.9044429629421187, 0.4620266401793388], ["Invert", 0.1803008045494473, 0.8073190766288534]], [["Sharpness", 0.7054649148075851, 0.3877207948962055], ["TranslateX", 0.49260224225927285, 0.8987462620731029]], [["Sharpness", 0.11196934729294483, 0.5953704422694938], ["Contrast", 0.13969334315069737, 0.19310569898434204]], [["Posterize", 0.5484346101051778, 0.7914140118600685], ["Brightness", 0.6428044691630473, 0.18811316670808076]], [["Invert", 0.22294834094984717, 0.05173157689962704], ["Cutout", 0.6091129168510456, 0.6280845506243643]], [["AutoContrast", 0.5726444076195267, 0.2799840903601295], ["Cutout", 0.3055752727786235, 0.591639807512993]], [["Brightness", 0.3707116723204462, 0.4049175910826627], ["Rotate", 0.4811601625588309, 0.2710760253723644]], [["ShearY", 0.627791719653608, 0.6877498291550205], ["TranslateX", 0.8751753308366824, 0.011164650018719358]], [["Posterize", 0.33832547954522263, 0.7087039872581657], ["Posterize", 0.6247474435007484, 0.7707784192114796]], [["Contrast", 0.17620186308493468, 0.9946224854942095], ["Solarize", 0.5431896088395964, 0.5867904203742308]], [["ShearX", 0.4667959516719652, 0.8938082224109446], ["TranslateY", 0.7311343008292865, 0.6829842246020277]], [["ShearX", 0.6130281467237769, 0.9924010909612302], ["Brightness", 0.41039241699696916, 0.9753218875311392]], [["TranslateY", 0.0747250386427123, 0.34602725521067534], ["Rotate", 0.5902597465515901, 0.361094672021087]], [["Invert", 0.05234890878959486, 0.36914978664919407], ["Sharpness", 0.42140532878231374, 0.19204058551048275]], [["ShearY", 0.11590485361909497, 0.6518540857972316], ["Invert", 0.6482444740361704, 0.48256237896163945]], [["Rotate", 0.4931329446923608, 0.037076242417301675], ["Contrast", 0.9097939772412852, 0.5619594905306389]], [["Posterize", 0.7311032479626216, 0.4796364593912915], ["Color", 0.13912123993932402, 0.03997286439663705]], [["AutoContrast", 0.6196602944085344, 0.2531430457527588], ["Rotate", 0.5583937060431972, 0.9893379795224023]], [["AutoContrast", 0.8847753125072959, 0.19123028952580057], ["TranslateY", 0.494361716097206, 0.14232297727461696]], [["Invert", 0.6212360716340707, 0.033898871473033165], ["AutoContrast", 0.30839896957008295, 0.23603569542166247]], [["Equalize", 0.8255583546605049, 0.613736933157845], ["AutoContrast", 0.6357166629525485, 0.7894617347709095]], [["Brightness", 0.33840706322846814, 0.07917167871493658], ["ShearY", 0.15693175752528676, 0.6282773652129153]], [["Cutout", 0.7550520024859294, 0.08982367300605598], ["ShearX", 0.5844942417320858, 0.36051195083380105]]] 308 | return p 309 | -------------------------------------------------------------------------------- /augmentations.py: -------------------------------------------------------------------------------- 1 | # code in this file is adpated from rpmcruz/autoaugment 2 | # https://github.com/rpmcruz/autoaugment/blob/master/transformations.py 3 | import random 4 | 5 | import PIL, PIL.ImageOps, PIL.ImageEnhance, PIL.ImageDraw 6 | import numpy as np 7 | 8 | random_mirror = True 9 | 10 | 11 | def ShearX(img, v): # [-0.3, 0.3] 12 | assert -0.3 <= v <= 0.3 13 | if random_mirror and random.random() > 0.5: 14 | v = -v 15 | return img.transform(img.size, PIL.Image.AFFINE, (1, v, 0, 0, 1, 0)) 16 | 17 | 18 | def ShearY(img, v): # [-0.3, 0.3] 19 | assert -0.3 <= v <= 0.3 20 | if random_mirror and random.random() > 0.5: 21 | v = -v 22 | return img.transform(img.size, PIL.Image.AFFINE, (1, 0, 0, v, 1, 0)) 23 | 24 | 25 | def TranslateX(img, v): # [-150, 150] => percentage: [-0.45, 0.45] 26 | assert -0.45 <= v <= 0.45 27 | if random_mirror and random.random() > 0.5: 28 | v = -v 29 | v = v * img.size[0] 30 | return img.transform(img.size, PIL.Image.AFFINE, (1, 0, v, 0, 1, 0)) 31 | 32 | 33 | def TranslateY(img, v): # [-150, 150] => percentage: [-0.45, 0.45] 34 | assert -0.45 <= v <= 0.45 35 | if random_mirror and random.random() > 0.5: 36 | v = -v 37 | v = v * img.size[1] 38 | return img.transform(img.size, PIL.Image.AFFINE, (1, 0, 0, 0, 1, v)) 39 | 40 | 41 | def TranslateXAbs(img, v): # [-150, 150] => percentage: [-0.45, 0.45] 42 | assert 0 <= v <= 10 43 | if random.random() > 0.5: 44 | v = -v 45 | return img.transform(img.size, PIL.Image.AFFINE, (1, 0, v, 0, 1, 0)) 46 | 47 | 48 | def TranslateYAbs(img, v): # [-150, 150] => percentage: [-0.45, 0.45] 49 | assert 0 <= v <= 10 50 | if random.random() > 0.5: 51 | v = -v 52 | return img.transform(img.size, PIL.Image.AFFINE, (1, 0, 0, 0, 1, v)) 53 | 54 | 55 | def Rotate(img, v): # [-30, 30] 56 | assert -30 <= v <= 30 57 | if random_mirror and random.random() > 0.5: 58 | v = -v 59 | return img.rotate(v) 60 | 61 | 62 | def AutoContrast(img, _): 63 | return PIL.ImageOps.autocontrast(img) 64 | 65 | 66 | def Invert(img, _): 67 | return PIL.ImageOps.invert(img) 68 | 69 | 70 | def Equalize(img, _): 71 | return PIL.ImageOps.equalize(img) 72 | 73 | 74 | def Flip(img, _): # not from the paper 75 | return PIL.ImageOps.mirror(img) 76 | 77 | 78 | def Solarize(img, v): # [0, 256] 79 | assert 0 <= v <= 256 80 | return PIL.ImageOps.solarize(img, v) 81 | 82 | 83 | def Posterize(img, v): # [4, 8] 84 | assert 4 <= v <= 8 85 | v = int(v) 86 | return PIL.ImageOps.posterize(img, v) 87 | 88 | 89 | def Posterize2(img, v): # [0, 4] 90 | assert 0 <= v <= 4 91 | v = int(v) 92 | return PIL.ImageOps.posterize(img, v) 93 | 94 | 95 | def Contrast(img, v): # [0.1,1.9] 96 | assert 0.1 <= v <= 1.9 97 | return PIL.ImageEnhance.Contrast(img).enhance(v) 98 | 99 | 100 | def Color(img, v): # [0.1,1.9] 101 | assert 0.1 <= v <= 1.9 102 | return PIL.ImageEnhance.Color(img).enhance(v) 103 | 104 | 105 | def Brightness(img, v): # [0.1,1.9] 106 | assert 0.1 <= v <= 1.9 107 | return PIL.ImageEnhance.Brightness(img).enhance(v) 108 | 109 | 110 | def Sharpness(img, v): # [0.1,1.9] 111 | assert 0.1 <= v <= 1.9 112 | return PIL.ImageEnhance.Sharpness(img).enhance(v) 113 | 114 | 115 | def Cutout(img, v): # [0, 60] => percentage: [0, 0.2] 116 | assert 0.0 <= v <= 0.2 117 | if v <= 0.: 118 | return img 119 | 120 | v = v * img.size[0] 121 | 122 | return CutoutAbs(img, v) 123 | 124 | # x0 = np.random.uniform(w - v) 125 | # y0 = np.random.uniform(h - v) 126 | # xy = (x0, y0, x0 + v, y0 + v) 127 | # color = (127, 127, 127) 128 | # img = img.copy() 129 | # PIL.ImageDraw.Draw(img).rectangle(xy, color) 130 | # return img 131 | 132 | 133 | def CutoutAbs(img, v): # [0, 60] => percentage: [0, 0.2] 134 | # assert 0 <= v <= 20 135 | if v < 0: 136 | return img 137 | w, h = img.size 138 | x0 = np.random.uniform(w) 139 | y0 = np.random.uniform(h) 140 | 141 | x0 = int(max(0, x0 - v / 2.)) 142 | y0 = int(max(0, y0 - v / 2.)) 143 | x1 = min(w, x0 + v) 144 | y1 = min(h, y0 + v) 145 | 146 | xy = (x0, y0, x1, y1) 147 | color = (125, 123, 114) 148 | # color = (0, 0, 0) 149 | img = img.copy() 150 | PIL.ImageDraw.Draw(img).rectangle(xy, color) 151 | return img 152 | 153 | 154 | def SamplePairing(imgs): # [0, 0.4] 155 | def f(img1, v): 156 | i = np.random.choice(len(imgs)) 157 | img2 = PIL.Image.fromarray(imgs[i]) 158 | return PIL.Image.blend(img1, img2, v) 159 | 160 | return f 161 | 162 | 163 | def augment_list(for_autoaug=True): # 16 operations and their ranges 164 | l = [ 165 | (ShearX, -0.3, 0.3), # 0 166 | (ShearY, -0.3, 0.3), # 1 167 | (TranslateX, -0.45, 0.45), # 2 168 | (TranslateY, -0.45, 0.45), # 3 169 | (Rotate, -30, 30), # 4 170 | (AutoContrast, 0, 1), # 5 171 | (Invert, 0, 1), # 6 172 | (Equalize, 0, 1), # 7 173 | (Solarize, 0, 256), # 8 174 | (Posterize, 4, 8), # 9 175 | (Contrast, 0.1, 1.9), # 10 176 | (Color, 0.1, 1.9), # 11 177 | (Brightness, 0.1, 1.9), # 12 178 | (Sharpness, 0.1, 1.9), # 13 179 | (Cutout, 0, 0.2), # 14 180 | # (SamplePairing(imgs), 0, 0.4), # 15 181 | ] 182 | if for_autoaug: 183 | l += [ 184 | (CutoutAbs, 0, 20), # compatible with auto-augment 185 | (Posterize2, 0, 4), # 9 186 | (TranslateXAbs, 0, 10), # 9 187 | (TranslateYAbs, 0, 10), # 9 188 | ] 189 | return l 190 | 191 | 192 | augment_dict = {fn.__name__: (fn, v1, v2) for fn, v1, v2 in augment_list()} 193 | 194 | 195 | def get_augment(name): 196 | return augment_dict[name] 197 | 198 | 199 | def apply_augment(img, name, level): 200 | augment_fn, low, high = get_augment(name) 201 | return augment_fn(img.copy(), level * (high - low) + low) 202 | -------------------------------------------------------------------------------- /common.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | formatter = logging.Formatter('[%(asctime)s] [%(name)s] [%(levelname)s] %(message)s') 4 | 5 | 6 | def get_logger(name, level=logging.DEBUG): 7 | logger = logging.getLogger(name) 8 | logger.handlers.clear() 9 | logger.setLevel(level) 10 | ch = logging.StreamHandler() 11 | ch.setLevel(level) 12 | ch.setFormatter(formatter) 13 | logger.addHandler(ch) 14 | return logger 15 | 16 | 17 | def add_filehandler(logger, filepath): 18 | fh = logging.FileHandler(filepath) 19 | fh.setLevel(logging.DEBUG) 20 | fh.setFormatter(formatter) 21 | logger.addHandler(fh) 22 | -------------------------------------------------------------------------------- /confs/wresnet28x2.yaml: -------------------------------------------------------------------------------- 1 | model: 2 | type: wresnet28_2 3 | dataset: cifar10 4 | aug: fa_reduced_cifar10 # autoaug_extend 5 | cutout: 16 6 | 7 | # UDA-related hyperparams 8 | batch: 32 9 | batch_unsup: 960 10 | ratio_unsup: 5.0 11 | ratio_mode: 'constant' 12 | 13 | # training params 14 | epoch: 1600 15 | lr: 0.0001 16 | lr_schedule: 17 | type: 'cosine' 18 | warmup: 19 | multiplier: 300 20 | epoch: 120 21 | optimizer: 22 | type: sgd 23 | nesterov: True 24 | decay: 0.0005 25 | -------------------------------------------------------------------------------- /data.py: -------------------------------------------------------------------------------- 1 | import logging 2 | import os 3 | import numpy as np 4 | import torch 5 | import torchvision 6 | from PIL import Image 7 | 8 | from torch.utils.data import SubsetRandomSampler, Subset, Dataset 9 | from torchvision.transforms import transforms 10 | from sklearn.model_selection import StratifiedShuffleSplit 11 | from theconf import Config as C 12 | 13 | from archive import autoaug_policy, autoaug_paper_cifar10, fa_reduced_cifar10 14 | from augmentations import * 15 | from common import get_logger 16 | from samplers.stratified_sampler import StratifiedSampler 17 | 18 | logger = get_logger('Unsupervised Data Augmentation') 19 | logger.setLevel(logging.INFO) 20 | 21 | 22 | def get_dataloaders(dataset, batch, batch_unsup, dataroot): 23 | if 'cifar' in dataset: 24 | transform_train = transforms.Compose([ 25 | transforms.RandomCrop(32, padding=4), 26 | transforms.RandomHorizontalFlip(), 27 | transforms.ToTensor(), 28 | transforms.Normalize((0.4914, 0.4822, 0.4465), (0.2023, 0.1994, 0.2010)), 29 | ]) 30 | transform_valid = transforms.Compose([ 31 | transforms.RandomCrop(32, padding=4), 32 | transforms.RandomHorizontalFlip(), 33 | transforms.ToTensor(), 34 | transforms.Normalize((0.4914, 0.4822, 0.4465), (0.2023, 0.1994, 0.2010)), 35 | ]) 36 | transform_test = transforms.Compose([ 37 | transforms.ToTensor(), 38 | transforms.Normalize((0.4914, 0.4822, 0.4465), (0.2023, 0.1994, 0.2010)), 39 | ]) 40 | else: 41 | raise ValueError('dataset=%s' % dataset) 42 | 43 | autoaug = transforms.Compose([]) 44 | if isinstance(C.get()['aug'], list): 45 | logger.debug('augmentation provided.') 46 | autoaug.transforms.insert(0, Augmentation(C.get()['aug'])) 47 | else: 48 | logger.debug('augmentation: %s' % C.get()['aug']) 49 | if C.get()['aug'] == 'fa_reduced_cifar10': 50 | autoaug.transforms.insert(0, Augmentation(fa_reduced_cifar10())) 51 | elif C.get()['aug'] == 'autoaug_cifar10': 52 | autoaug.transforms.insert(0, Augmentation(autoaug_paper_cifar10())) 53 | elif C.get()['aug'] == 'autoaug_extend': 54 | autoaug.transforms.insert(0, Augmentation(autoaug_policy())) 55 | elif C.get()['aug'] == 'default': 56 | pass 57 | else: 58 | raise ValueError('not found augmentations. %s' % C.get()['aug']) 59 | transform_train.transforms.insert(0, autoaug) 60 | 61 | if C.get()['cutout'] > 0: 62 | transform_train.transforms.append(CutoutDefault(C.get()['cutout'])) 63 | 64 | if dataset in ['cifar10', 'cifar100']: 65 | if dataset == 'cifar10': 66 | total_trainset = torchvision.datasets.CIFAR10(root=dataroot, train=True, download=True, transform=transform_train) 67 | unsup_trainset = torchvision.datasets.CIFAR10(root=dataroot, train=True, download=True, transform=None) 68 | testset = torchvision.datasets.CIFAR10(root=dataroot, train=False, download=True, transform=transform_test) 69 | elif dataset == 'cifar100': 70 | total_trainset = torchvision.datasets.CIFAR100(root=dataroot, train=True, download=True, transform=transform_train) 71 | unsup_trainset = torchvision.datasets.CIFAR100(root=dataroot, train=True, download=True, transform=None) 72 | testset = torchvision.datasets.CIFAR100(root=dataroot, train=False, download=True, transform=transform_test) 73 | else: 74 | raise ValueError 75 | 76 | sss = StratifiedShuffleSplit(n_splits=1, test_size=46000, random_state=0) # 4000 trainset 77 | sss = sss.split(list(range(len(total_trainset))), total_trainset.targets) 78 | train_idx, valid_idx = next(sss) 79 | train_labels = [total_trainset.targets[idx] for idx in train_idx] 80 | 81 | trainset = Subset(total_trainset, train_idx) # for supervised 82 | trainset.train_labels = train_labels 83 | 84 | otherset = Subset(unsup_trainset, valid_idx) # for unsupervised 85 | # otherset = unsup_trainset 86 | otherset = UnsupervisedDataset(otherset, transform_valid, autoaug, cutout=C.get()['cutout']) 87 | else: 88 | raise ValueError('invalid dataset name=%s' % dataset) 89 | 90 | trainloader = torch.utils.data.DataLoader( 91 | trainset, batch_size=batch, shuffle=False, num_workers=8, pin_memory=True, 92 | sampler=StratifiedSampler(trainset.train_labels), drop_last=True) 93 | 94 | unsuploader = torch.utils.data.DataLoader( 95 | otherset, batch_size=batch_unsup, shuffle=True, num_workers=8, pin_memory=True, 96 | sampler=None, drop_last=True) 97 | 98 | testloader = torch.utils.data.DataLoader( 99 | testset, batch_size=batch, shuffle=False, num_workers=32, pin_memory=True, 100 | drop_last=False 101 | ) 102 | return trainloader, unsuploader, testloader 103 | 104 | 105 | class CutoutDefault(object): 106 | """ 107 | Reference : https://github.com/quark0/darts/blob/master/cnn/utils.py 108 | """ 109 | def __init__(self, length): 110 | self.length = length 111 | 112 | def __call__(self, img): 113 | if self.length <= 0: 114 | return img 115 | h, w = img.size(1), img.size(2) 116 | mask = np.ones((h, w), np.float32) 117 | y = np.random.randint(h) 118 | x = np.random.randint(w) 119 | 120 | y1 = np.clip(y - self.length // 2, 0, h) 121 | y2 = np.clip(y + self.length // 2, 0, h) 122 | x1 = np.clip(x - self.length // 2, 0, w) 123 | x2 = np.clip(x + self.length // 2, 0, w) 124 | 125 | mask[y1: y2, x1: x2] = 0. 126 | mask = torch.from_numpy(mask) 127 | mask = mask.expand_as(img) 128 | img *= mask 129 | return img 130 | 131 | 132 | class Augmentation(object): 133 | def __init__(self, policies): 134 | self.policies = policies 135 | 136 | def __call__(self, img): 137 | for _ in range(1): 138 | policy = random.choice(self.policies) 139 | for name, pr, level in policy: 140 | if random.random() > pr: 141 | continue 142 | img = apply_augment(img, name, level) 143 | return img 144 | 145 | 146 | class UnsupervisedDataset(Dataset): 147 | def __init__(self, dataset, transform_default, transform_aug, cutout=0): 148 | self.dataset = dataset 149 | self.transform_default = transform_default 150 | self.transform_aug = transform_aug 151 | self.transform_cutout = CutoutDefault(cutout) # issue 4 : https://github.com/ildoonet/unsupervised-data-augmentation/issues/4 152 | 153 | def __getitem__(self, index): 154 | img, _ = self.dataset[index] 155 | 156 | img1 = self.transform_default(img) 157 | img2 = self.transform_default(self.transform_aug(img)) 158 | img2 = self.transform_cutout(img2) 159 | 160 | return img1, img2 161 | 162 | def __len__(self): 163 | return len(self.dataset) 164 | -------------------------------------------------------------------------------- /metrics.py: -------------------------------------------------------------------------------- 1 | import copy 2 | 3 | import torch 4 | from collections import defaultdict 5 | 6 | from torch import nn 7 | 8 | 9 | def accuracy(output, target, topk=(1,)): 10 | """Computes the precision@k for the specified values of k""" 11 | maxk = max(topk) 12 | batch_size = target.size(0) 13 | 14 | _, pred = output.topk(maxk, 1, True, True) 15 | pred = pred.t() 16 | correct = pred.eq(target.view(1, -1).expand_as(pred)) 17 | 18 | res = [] 19 | for k in topk: 20 | correct_k = correct[:k].view(-1).float().sum(0) 21 | res.append(correct_k.mul_(1. / batch_size)) 22 | return res 23 | 24 | 25 | def cross_entropy_smooth(input, target, size_average=True, label_smoothing=0.1): 26 | y = torch.eye(10).cuda() 27 | lb_oh = y[target] 28 | 29 | target = lb_oh * (1 - label_smoothing) + 0.5 * label_smoothing 30 | 31 | logsoftmax = nn.LogSoftmax() 32 | if size_average: 33 | return torch.mean(torch.sum(-target * logsoftmax(input), dim=1)) 34 | else: 35 | return torch.sum(torch.sum(-target * logsoftmax(input), dim=1)) 36 | 37 | 38 | class Accumulator: 39 | def __init__(self): 40 | self.metrics = defaultdict(lambda: 0.) 41 | 42 | def add(self, key, value): 43 | self.metrics[key] += value 44 | 45 | def add_dict(self, dict): 46 | for key, value in dict.items(): 47 | self.add(key, value) 48 | 49 | def __getitem__(self, item): 50 | return self.metrics[item] 51 | 52 | def __setitem__(self, key, value): 53 | self.metrics[key] = value 54 | 55 | def get_dict(self): 56 | return copy.deepcopy(dict(self.metrics)) 57 | 58 | def items(self): 59 | return self.metrics.items() 60 | 61 | def __str__(self): 62 | return str(dict(self.metrics)) 63 | 64 | def __truediv__(self, other): 65 | newone = Accumulator() 66 | for key, value in self.items(): 67 | if isinstance(other, str): 68 | if other != key: 69 | newone[key] = value / self[other] 70 | else: 71 | newone[key] = value 72 | else: 73 | newone[key] = value / other 74 | return newone 75 | 76 | 77 | class SummaryWriterDummy: 78 | def __init__(self, logdir): 79 | pass 80 | 81 | def add_scalar(self, *args, **kwargs): 82 | pass 83 | -------------------------------------------------------------------------------- /networks/__init__.py: -------------------------------------------------------------------------------- 1 | import torch 2 | from pretrainedmodels import models 3 | 4 | from torch import nn 5 | from torch.nn import DataParallel 6 | import torch.backends.cudnn as cudnn 7 | 8 | from networks.wideresnet import WideResNet 9 | 10 | 11 | def get_model(conf, num_class=10, data_parallel=True): 12 | name = conf['type'] 13 | 14 | if name == 'wresnet40_2': 15 | model = WideResNet(40, 2, dropout_rate=0.0, num_classes=num_class) 16 | elif name == 'wresnet28_2': 17 | model = WideResNet(28, 2, dropout_rate=0.0, num_classes=num_class) 18 | elif name == 'wresnet28_10': 19 | model = WideResNet(28, 10, dropout_rate=0.0, num_classes=num_class) 20 | 21 | else: 22 | raise NameError('no model named, %s' % name) 23 | 24 | if data_parallel: 25 | model = model.cuda() 26 | model = DataParallel(model) 27 | else: 28 | import horovod.torch as hvd 29 | device = torch.device('cuda', hvd.local_rank()) 30 | model = model.to(device) 31 | cudnn.benchmark = True 32 | return model 33 | 34 | 35 | def num_class(dataset): 36 | return { 37 | 'cifar10': 10, 38 | 'reduced_cifar10': 10, 39 | 'cifar100': 100, 40 | 'imagenet': 1000, 41 | 'reduced_imagenet': 120, 42 | }[dataset] 43 | -------------------------------------------------------------------------------- /networks/wideresnet.py: -------------------------------------------------------------------------------- 1 | import torch.nn as nn 2 | import torch.nn.init as init 3 | import torch.nn.functional as F 4 | import numpy as np 5 | 6 | 7 | bn_momentum = 0.9 8 | 9 | 10 | def conv3x3(in_planes, out_planes, stride=1): 11 | return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride, padding=1, bias=True) 12 | 13 | 14 | def conv_init(m): 15 | classname = m.__class__.__name__ 16 | if classname.find('Conv') != -1: 17 | init.xavier_uniform_(m.weight, gain=np.sqrt(2)) 18 | init.constant_(m.bias, 0) 19 | elif classname.find('BatchNorm') != -1: 20 | init.constant_(m.weight, 1) 21 | init.constant_(m.bias, 0) 22 | 23 | 24 | class WideBasic(nn.Module): 25 | def __init__(self, in_planes, planes, dropout_rate, stride=1): 26 | super(WideBasic, self).__init__() 27 | self.bn1 = nn.BatchNorm2d(in_planes, momentum=bn_momentum) 28 | self.conv1 = nn.Conv2d(in_planes, planes, kernel_size=3, padding=1, bias=True) 29 | self.dropout = nn.Dropout(p=dropout_rate) 30 | self.bn2 = nn.BatchNorm2d(planes, momentum=bn_momentum) 31 | self.conv2 = nn.Conv2d(planes, planes, kernel_size=3, stride=stride, padding=1, bias=True) 32 | 33 | self.shortcut = nn.Sequential() 34 | if stride != 1 or in_planes != planes: 35 | self.shortcut = nn.Sequential( 36 | nn.Conv2d(in_planes, planes, kernel_size=1, stride=stride, bias=True), 37 | ) 38 | 39 | def forward(self, x): 40 | out = self.dropout(self.conv1(F.relu(self.bn1(x)))) 41 | out = self.conv2(F.relu(self.bn2(out))) 42 | out += self.shortcut(x) 43 | 44 | return out 45 | 46 | 47 | class WideResNet(nn.Module): 48 | def __init__(self, depth, widen_factor, dropout_rate, num_classes): 49 | super(WideResNet, self).__init__() 50 | self.in_planes = 16 51 | 52 | assert ((depth - 4) % 6 == 0), 'Wide-resnet depth should be 6n+4' 53 | n = int((depth - 4) / 6) 54 | k = widen_factor 55 | 56 | nStages = [16, 16*k, 32*k, 64*k] 57 | 58 | self.conv1 = conv3x3(3, nStages[0]) 59 | self.layer1 = self._wide_layer(WideBasic, nStages[1], n, dropout_rate, stride=1) 60 | self.layer2 = self._wide_layer(WideBasic, nStages[2], n, dropout_rate, stride=2) 61 | self.layer3 = self._wide_layer(WideBasic, nStages[3], n, dropout_rate, stride=2) 62 | self.bn1 = nn.BatchNorm2d(nStages[3], momentum=bn_momentum) 63 | self.linear = nn.Linear(nStages[3], num_classes) 64 | 65 | # self.apply(conv_init) 66 | 67 | def _wide_layer(self, block, planes, num_blocks, dropout_rate, stride): 68 | strides = [stride] + [1]*(num_blocks-1) 69 | layers = [] 70 | 71 | for stride in strides: 72 | layers.append(block(self.in_planes, planes, dropout_rate, stride)) 73 | self.in_planes = planes 74 | 75 | return nn.Sequential(*layers) 76 | 77 | def forward(self, x): 78 | out = self.conv1(x) 79 | out = self.layer1(out) 80 | out = self.layer2(out) 81 | out = self.layer3(out) 82 | out = F.relu(self.bn1(out)) 83 | # out = F.avg_pool2d(out, 8) 84 | out = F.adaptive_avg_pool2d(out, (1, 1)) 85 | out = out.view(out.size(0), -1) 86 | out = self.linear(out) 87 | 88 | return out 89 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | git+https://github.com/wbaek/theconf@de32022f8c0651a043dc812d17194cdfd62066e8 2 | git+https://github.com/ildoonet/pytorch-gradual-warmup-lr.git@v0.2 3 | git+https://github.com/ildoonet/pystopwatch2.git 4 | pretrainedmodels 5 | tqdm 6 | tensorboardx 7 | sklearn 8 | matplotlib 9 | psutil 10 | requests 11 | -------------------------------------------------------------------------------- /samplers/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ildoonet/unsupervised-data-augmentation/a2356e4af6b84f56740796d461719229cedc61fd/samplers/__init__.py -------------------------------------------------------------------------------- /samplers/stratified_sampler.py: -------------------------------------------------------------------------------- 1 | import random 2 | from collections import defaultdict 3 | 4 | from torch.utils.data import Sampler 5 | 6 | 7 | class StratifiedSampler(Sampler): 8 | def __init__(self, labels): 9 | self.idx_by_lb = defaultdict(list) 10 | for idx, lb in enumerate(labels): 11 | self.idx_by_lb[lb].append(idx) 12 | 13 | self.size = len(labels) 14 | 15 | def __len__(self): 16 | return self.size 17 | 18 | def __iter__(self): 19 | songs_list = [] 20 | artists_list = [] 21 | for lb, v in self.idx_by_lb.items(): 22 | for idx in v: 23 | songs_list.append(idx) 24 | artists_list.append(lb) 25 | 26 | shuffled = spotifyShuffle(songs_list, artists_list) 27 | return iter(shuffled) 28 | 29 | 30 | def fisherYatesShuffle(arr): 31 | """ 32 | https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle 33 | for i from n−1 downto 1 do 34 | j ← random integer such that 0 ≤ j ≤ i 35 | exchange a[j] and a[i] 36 | """ 37 | for i in range(len(arr)-1, 0, -1): 38 | j = random.randint(0, i) 39 | arr[i], arr[j] = arr[j], arr[i] 40 | return arr 41 | 42 | 43 | def spotifyShuffle(songs_list, artists_list): 44 | artist2songs = defaultdict(list) 45 | for artist, song in zip(artists_list, songs_list): 46 | artist2songs[artist].append(song) 47 | songList = [] 48 | songsLocs = [] 49 | for artist, songs in artist2songs.items(): 50 | songs = fisherYatesShuffle(songs) 51 | songList += songs 52 | songsLocs += get_locs(len(songs)) 53 | return [songList[idx] for idx in argsort(songsLocs)] 54 | 55 | 56 | def argsort(seq): 57 | return [i for i, j in sorted(enumerate(seq), key=lambda x:x[1])] 58 | 59 | 60 | def get_locs(n): 61 | percent = 1. / n 62 | locs = [percent * random.random()] 63 | last = locs[0] 64 | for i in range(n - 1): 65 | value = last + percent * random.uniform(0.8, 1.2) # 25% : 20~30% = 1 : 0.8x~1.2x 66 | locs.append(value) 67 | last = value 68 | return locs 69 | -------------------------------------------------------------------------------- /train.py: -------------------------------------------------------------------------------- 1 | import itertools 2 | import logging 3 | import math 4 | import os 5 | from collections import OrderedDict 6 | 7 | import torch 8 | from torch import nn, optim 9 | from torch.nn.functional import kl_div, softmax, log_softmax 10 | 11 | from tqdm import tqdm 12 | from theconf import Config as C, ConfigArgumentParser 13 | 14 | from common import get_logger 15 | from data import get_dataloaders 16 | from metrics import accuracy, Accumulator 17 | from networks import get_model, num_class 18 | 19 | from warmup_scheduler import GradualWarmupScheduler 20 | 21 | 22 | logger = get_logger('Unsupervised Data Augmentation') 23 | logger.setLevel(logging.INFO) 24 | 25 | best_valid_top1 = 0 26 | 27 | 28 | def run_epoch(model, loader_s, loader_u, loss_fn, optimizer, desc_default='', epoch=0, writer=None, verbose=1, unsupervised=False, scheduler=None): 29 | tqdm_disable = bool(os.environ.get('TASK_NAME', '')) 30 | if verbose: 31 | loader_s = tqdm(loader_s, disable=tqdm_disable) 32 | loader_s.set_description('[%s %04d/%04d]' % (desc_default, epoch, C.get()['epoch'])) 33 | 34 | iter_u = iter(loader_u) 35 | 36 | metrics = Accumulator() 37 | cnt = 0 38 | total_steps = len(loader_s) 39 | steps = 0 40 | for data, label in loader_s: 41 | steps += 1 42 | 43 | if not unsupervised: 44 | data, label = data.cuda(), label.cuda() 45 | preds = model(data) 46 | loss = loss_fn(preds, label) # loss for supervised learning 47 | else: 48 | label = label.cuda() 49 | try: 50 | unlabel1, unlabel2 = next(iter_u) 51 | except StopIteration: 52 | iter_u = iter(loader_u) 53 | unlabel1, unlabel2 = next(iter_u) 54 | data_all = torch.cat([data, unlabel1, unlabel2]).cuda() 55 | 56 | preds_all = model(data_all) 57 | preds = preds_all[:len(data)] 58 | loss = loss_fn(preds, label) # loss for supervised learning 59 | 60 | preds_unsup = preds_all[len(data):] 61 | preds1, preds2 = torch.chunk(preds_unsup, 2) 62 | preds1 = softmax(preds1, dim=1).detach() 63 | preds2 = log_softmax(preds2, dim=1) 64 | assert len(preds1) == len(preds2) == C.get()['batch_unsup'] 65 | 66 | loss_kldiv = kl_div(preds2, preds1, reduction='none') # loss for unsupervised 67 | loss_kldiv = torch.sum(loss_kldiv, dim=1) 68 | assert len(loss_kldiv) == len(unlabel1) 69 | # loss += (epoch / 200. * C.get()['ratio_unsup']) * torch.mean(loss_kldiv) 70 | if C.get()['ratio_mode'] == 'constant': 71 | loss += C.get()['ratio_unsup'] * torch.mean(loss_kldiv) 72 | elif C.get()['ratio_mode'] == 'gradual': 73 | loss += (epoch / float(C.get()['epoch'])) * C.get()['ratio_unsup'] * torch.mean(loss_kldiv) 74 | else: 75 | raise ValueError 76 | 77 | if optimizer: 78 | loss.backward() 79 | if C.get()['optimizer'].get('clip', 5) > 0: 80 | nn.utils.clip_grad_norm_(model.parameters(), C.get()['optimizer'].get('clip', 5)) 81 | 82 | optimizer.step() 83 | optimizer.zero_grad() 84 | 85 | top1, top5 = accuracy(preds, label, (1, 5)) 86 | 87 | metrics.add_dict({ 88 | 'loss': loss.item() * len(data), 89 | 'top1': top1.item() * len(data), 90 | 'top5': top5.item() * len(data), 91 | }) 92 | cnt += len(data) 93 | if verbose: 94 | postfix = metrics / cnt 95 | if optimizer: 96 | postfix['lr'] = optimizer.param_groups[0]['lr'] 97 | loader_s.set_postfix(postfix) 98 | 99 | if scheduler is not None: 100 | scheduler.step(epoch - 1 + float(steps) / total_steps) 101 | 102 | del preds, loss, top1, top5, data, label 103 | 104 | if tqdm_disable: 105 | logger.info('[%s %03d/%03d] %s', desc_default, epoch, C.get()['epoch'], metrics / cnt) 106 | 107 | metrics /= cnt 108 | if optimizer: 109 | metrics.metrics['lr'] = optimizer.param_groups[0]['lr'] 110 | if verbose: 111 | for key, value in metrics.items(): 112 | writer.add_scalar(key, value, epoch) 113 | return metrics 114 | 115 | 116 | def train_and_eval(tag, dataroot, metric='last', save_path=None, only_eval=False, unsupervised=False): 117 | max_epoch = C.get()['epoch'] 118 | trainloader, unsuploader, testloader = get_dataloaders(C.get()['dataset'], C.get()['batch'], C.get()['batch_unsup'], dataroot) 119 | 120 | # create a model & an optimizer 121 | model = get_model(C.get()['model'], num_class(C.get()['dataset']), data_parallel=True) 122 | 123 | criterion = nn.CrossEntropyLoss() 124 | if C.get()['optimizer']['type'] == 'sgd': 125 | optimizer = optim.SGD( 126 | model.parameters(), 127 | lr=C.get()['lr'], 128 | momentum=C.get()['optimizer'].get('momentum', 0.9), 129 | weight_decay=C.get()['optimizer']['decay'], 130 | nesterov=C.get()['optimizer']['nesterov'] 131 | ) 132 | else: 133 | raise ValueError('invalid optimizer type=%s' % C.get()['optimizer']['type']) 134 | 135 | lr_scheduler_type = C.get()['lr_schedule'].get('type', 'cosine') 136 | if lr_scheduler_type == 'cosine': 137 | t_max = C.get()['epoch'] 138 | if C.get()['lr_schedule'].get('warmup', None): 139 | t_max -= C.get()['lr_schedule']['warmup']['epoch'] 140 | scheduler = torch.optim.lr_scheduler.CosineAnnealingLR(optimizer, T_max=t_max, eta_min=0.) 141 | else: 142 | raise ValueError('invalid lr_schduler=%s' % lr_scheduler_type) 143 | 144 | if C.get()['lr_schedule'].get('warmup', None): 145 | scheduler = GradualWarmupScheduler( 146 | optimizer, 147 | multiplier=C.get()['lr_schedule']['warmup']['multiplier'], 148 | total_epoch=C.get()['lr_schedule']['warmup']['epoch'], 149 | after_scheduler=scheduler 150 | ) 151 | 152 | if not tag.strip(): 153 | from metrics import SummaryWriterDummy as SummaryWriter 154 | logger.warning('tag not provided, no tensorboard log.') 155 | else: 156 | from tensorboardX import SummaryWriter 157 | writers = [SummaryWriter(logdir='./logs/%s/%s' % (tag, x)) for x in ['train', 'test']] 158 | 159 | result = OrderedDict() 160 | epoch_start = 1 161 | if save_path and os.path.exists(save_path): 162 | data = torch.load(save_path) 163 | model.load_state_dict(data['model']) 164 | optimizer.load_state_dict(data['optimizer']) 165 | epoch_start = data['epoch'] 166 | 167 | if only_eval: 168 | logger.info('evaluation only+') 169 | model.eval() 170 | rs = dict() 171 | rs['test'] = run_epoch(model, testloader, unsuploader, criterion, None, desc_default='*test', epoch=epoch_start, writer=writers[1]) 172 | for key, setname in itertools.product(['loss', 'top1', 'top5'], ['train', 'test']): 173 | result['%s_%s' % (key, setname)] = rs[setname][key] 174 | result['epoch'] = 0 175 | return result 176 | 177 | # train loop 178 | global best_valid_top1 179 | best_valid_loss = 10e10 180 | for epoch in range(epoch_start, max_epoch + 1): 181 | model.train() 182 | rs = dict() 183 | rs['train'] = run_epoch(model, trainloader, unsuploader, criterion, optimizer, desc_default='train', epoch=epoch, writer=writers[0], verbose=True, unsupervised=unsupervised, scheduler=scheduler) 184 | if math.isnan(rs['train']['loss']): 185 | raise Exception('train loss is NaN.') 186 | 187 | model.eval() 188 | if epoch % (10 if 'cifar' in C.get()['dataset'] else 30) == 0 or epoch == max_epoch: 189 | rs['test'] = run_epoch(model, testloader, unsuploader, criterion, None, desc_default='*test', epoch=epoch, writer=writers[1], verbose=True) 190 | 191 | if best_valid_top1 < rs['test']['top1']: 192 | best_valid_top1 = rs['test']['top1'] 193 | 194 | if metric == 'last' or rs[metric]['loss'] < best_valid_loss: # TODO 195 | if metric != 'last': 196 | best_valid_loss = rs[metric]['loss'] 197 | for key, setname in itertools.product(['loss', 'top1', 'top5'], ['train', 'test']): 198 | result['%s_%s' % (key, setname)] = rs[setname][key] 199 | result['epoch'] = epoch 200 | 201 | writers[1].add_scalar('test_top1/best', rs['test']['top1'], epoch) 202 | 203 | # save checkpoint 204 | if save_path: 205 | logger.info('save model@%d to %s' % (epoch, save_path)) 206 | torch.save({ 207 | 'epoch': epoch, 208 | 'log': { 209 | 'train': rs['train'].get_dict(), 210 | 'test': rs['test'].get_dict(), 211 | }, 212 | 'optimizer': optimizer.state_dict(), 213 | 'model': model.state_dict() 214 | }, save_path) 215 | 216 | del model 217 | 218 | return result 219 | 220 | 221 | if __name__ == '__main__': 222 | parser = ConfigArgumentParser(conflict_handler='resolve') 223 | parser.add_argument('--tag', type=str, default='') 224 | parser.add_argument('--dataroot', type=str, default='/data/private/pretrainedmodels', help='torchvision data folder') 225 | parser.add_argument('--save', type=str, default='') 226 | parser.add_argument('--decay', type=float, default=-1) 227 | parser.add_argument('--unsupervised', action='store_true') 228 | parser.add_argument('--only-eval', action='store_true') 229 | args = parser.parse_args() 230 | 231 | assert (args.only_eval and not args.save) or not args.only_eval, 'checkpoint path not provided in evaluation mode.' 232 | 233 | if args.decay > 0: 234 | logger.info('decay reset=%.8f' % args.decay) 235 | C.get()['optimizer']['decay'] = args.decay 236 | if args.save: 237 | logger.info('checkpoint will be saved at %s', args.save) 238 | logger.info('unsupervsed=%s', args.unsupervised) 239 | 240 | import time 241 | t = time.time() 242 | result = train_and_eval(args.tag, args.dataroot, save_path=args.save, only_eval=args.only_eval, unsupervised=args.unsupervised) 243 | elapsed = time.time() - t 244 | 245 | logger.info('training done.') 246 | logger.info('model: %s' % C.get()['model']) 247 | logger.info('augmentation: %s' % C.get()['aug']) 248 | logger.info(result) 249 | logger.info('elapsed time: %.3f Hours' % (elapsed / 3600.)) 250 | logger.info('top1 error in testset: %.4f' % (1. - result['top1_test'])) 251 | logger.info('best top1 error in testset: %.4f' % (1. - best_valid_top1)) 252 | --------------------------------------------------------------------------------