(model, test_loader)
| 180 | |
| 181 | |
| 182 | def testing(model, test_loader): |
| 183 | test_path = osp.join(args.output_dir, "test.tsv") |
| 184 | |
| 185 | test_top = untarget_test(model, test_loader) |
| 186 | with open(test_path, 'a') as af: |
| 187 | af.write('Test untarget\n') |
| 188 | columns = ['time', 'Acc'] |
| 189 | af.write('\t'.join(columns) + '\n') |
| 190 | localtime = time.asctime(time.localtime(time.time()))[4:-6] |
| 191 | test_cols = [ |
| 192 | localtime, |
| 193 | round(test_top, 2), |
| 194 | ] |
| 195 | af.write('\t'.join([str(c) for c in test_cols]) + '\n') |
| 196 | |
| 197 | test_top = target_test(model, test_loader) |
| 198 | with open(test_path, 'a') as af: |
| 199 | af.write('Test target\n') |
| 200 | columns = ['time', 'Acc'] |
| 201 | af.write('\t'.join(columns) + '\n') |
| 202 | localtime = time.asctime(time.localtime(time.time()))[4:-6] |
| 203 | test_cols = [ |
| 204 | localtime, |
| 205 | round(test_top, 2), |
| 206 | ] |
| 207 | af.write('\t'.join([str(c) for c in test_cols]) + '\n') |
| 208 | |
| 209 | test_top = clean_test(model, test_loader) |
| 210 | with open(test_path, 'a') as af: |
| 211 | af.write('Test clean\n') |
| 212 | columns = ['time', 'Acc'] |
| 213 | af.write('\t'.join(columns) + '\n') |
| 214 | localtime = time.asctime(time.localtime(time.time()))[4:-6] |
| 215 | test_cols = [ |
| 216 | localtime, |
| 217 | round(test_top, 2), |
| 218 | ] |
| 219 | af.write('\t'.join([str(c) for c in test_cols]) + '\n') |
| 220 | |
| 221 | |
| 222 | def generate_dataloader(args, normalize, seed): |
no test coverage detected