Skip to content

Commit 93e2530

Browse files
Fix python api of mean iou op. (#11797)
* Fix mean iou op. * Fix crop layer test. * Fix unitest * fix unitest.
1 parent ef68b91 commit 93e2530

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

python/paddle/fluid/layers/nn.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5078,12 +5078,12 @@ def mean_iou(input, label, num_classes):
50785078
out_correct = helper.create_tmp_variable(dtype='int32')
50795079
helper.append_op(
50805080
type="mean_iou",
5081-
inputs={"predictions": input,
5082-
"labels": label},
5081+
inputs={"Predictions": input,
5082+
"Labels": label},
50835083
outputs={
5084-
"out_mean_iou": out_mean_iou,
5085-
"out_wrong": out_wrong,
5086-
"out_correct": out_correct
5084+
"OutMeanIou": out_mean_iou,
5085+
"OutWrong": out_wrong,
5086+
"OutCorrect": out_correct
50875087
},
50885088
attrs={"num_classes": num_classes})
50895089
return out_mean_iou, out_wrong, out_correct

python/paddle/fluid/tests/unittests/test_layers.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ def test_maxout(self):
401401
self.assertIsNotNone(output)
402402
print(str(program))
403403

404-
def test_maxout(self):
404+
def test_crop(self):
405405
program = Program()
406406
with program_guard(program):
407407
x = layers.data(name='x', shape=[3, 5], dtype="float32")
@@ -410,6 +410,15 @@ def test_maxout(self):
410410
self.assertIsNotNone(output)
411411
print(str(program))
412412

413+
def test_mean_iou(self):
414+
program = Program()
415+
with program_guard(program):
416+
x = layers.data(name='x', shape=[16], dtype='float32')
417+
y = layers.data(name='label', shape=[1], dtype='int64')
418+
iou = layers.mean_iou(x, y, 2)
419+
self.assertIsNotNone(iou)
420+
print(str(program))
421+
413422

414423
if __name__ == '__main__':
415424
unittest.main()

0 commit comments

Comments
 (0)