Skip to content

Commit 97f40b5

Browse files
authored
fix loss
1 parent 2b43dde commit 97f40b5

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

test1.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
pretrained = 'imagenet'
2121
phases = ['test_A']
2222
use_gpu = torch.cuda.is_available()
23-
batch_size = 128
23+
batch_size = 32
2424
INPUT_WORKERS = 32
2525
checkpoint_filename = arch + '_' + pretrained
2626
best_check = 'checkpoint/' + checkpoint_filename + '_best.pth.tar' #tar
27-
input_size = 256 #[224, 256, 384, 480, 640]
28-
train_scale = 256
29-
test_scale = 256
27+
input_size = 224 #[224, 256, 384, 480, 640]
28+
train_scale = 224
29+
test_scale = 224
3030
AdaptiveAvgPool = True
3131

3232

@@ -158,6 +158,7 @@ def test_model (model, criterion):
158158
running_corrects = 0
159159
top1 = AverageMeter()
160160
top3 = AverageMeter()
161+
loss1 = AverageMeter()
161162
results = []
162163
aug_softmax = {}
163164

@@ -198,15 +199,16 @@ def test_model (model, criterion):
198199
prec3 = res[1]
199200
top1.update(prec1[0], inputs.data.size(0))
200201
top3.update(prec3[0], inputs.data.size(0))
202+
loss1.update(loss.data[0], inputs.size(0))
201203

202204
results += batch_to_list_of_dicts(pred_list, img_name_raw)
203205

204206
epoch_loss = running_loss / dataset_sizes[phase]
205207
epoch_acc = running_corrects / dataset_sizes[phase]
206208

207-
print('{} Loss: {:.6f} Acc: {:.6f}'.format(
208-
phase, epoch_loss, epoch_acc))
209-
print(' * Prec@1 {top1.avg:.6f} Prec@3 {top3.avg:.6f}'.format(top1=top1, top3=top3))
209+
# print('{} Loss: {:.6f} Acc: {:.6f}'.format(
210+
# phase, epoch_loss, epoch_acc))
211+
print(' * Prec@1 {top1.avg:.6f} Prec@3 {top3.avg:.6f} Loss@1 {loss1.avg:.6f}'.format(top1=top1, top3=top3, loss1=loss1))
210212

211213
with open(('result/%s_submit1_%s.json'%(checkpoint_filename, phase)), 'w') as f:
212214
json.dump(results, f)

0 commit comments

Comments
 (0)