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

Function testing

code/deep/ReMoS/CV_backdoor/eval.py:140–177  ·  view source on GitHub ↗
(model, test_loader)

Source from the content-addressed store, hash-verified

138
139
140def testing(model, test_loader):
141 test_path = osp.join(args.output_dir, "test2.tsv")
142
143 test_top = untarget_test(model, test_loader)
144 with open(test_path, 'a') as af:
145 af.write('Test untarget\n')
146 columns = ['time', 'Acc']
147 af.write('\t'.join(columns) + '\n')
148 localtime = time.asctime(time.localtime(time.time()))[4:-6]
149 test_cols = [
150 localtime,
151 round(test_top, 2),
152 ]
153 af.write('\t'.join([str(c) for c in test_cols]) + '\n')
154
155 test_top = target_test(model, test_loader)
156 with open(test_path, 'a') as af:
157 af.write('Test target\n')
158 columns = ['time', 'Acc']
159 af.write('\t'.join(columns) + '\n')
160 localtime = time.asctime(time.localtime(time.time()))[4:-6]
161 test_cols = [
162 localtime,
163 round(test_top, 2),
164 ]
165 af.write('\t'.join([str(c) for c in test_cols]) + '\n')
166
167 test_top = clean_test(model, test_loader)
168 with open(test_path, 'a') as af:
169 af.write('Test clean\n')
170 columns = ['time', 'Acc']
171 af.write('\t'.join(columns) + '\n')
172 localtime = time.asctime(time.localtime(time.time()))[4:-6]
173 test_cols = [
174 localtime,
175 round(test_top, 2),
176 ]
177 af.write('\t'.join([str(c) for c in test_cols]) + '\n')
178
179
180def generate_dataloader(args, normalize, seed):

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected