MCPcopy
hub / github.com/jindongwang/transferlearning / testing

Function testing

code/deep/ReMoS/CV_backdoor/finetune.py:182–219  ·  view source on GitHub ↗
(model, test_loader)

Source from the content-addressed store, hash-verified

180
181
182def 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
222def generate_dataloader(args, normalize, seed):

Callers 1

finetune.pyFile · 0.70

Calls 4

untarget_testFunction · 0.70
target_testFunction · 0.70
clean_testFunction · 0.70
writeMethod · 0.45

Tested by

no test coverage detected