Skip to content

Commit 5e7b169

Browse files
Fix python api of mean iou op. (#11797) (#11827)
* Fix mean iou op. * Fix crop layer test. * Fix unitest * fix unitest.
1 parent 5d4a110 commit 5e7b169

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
@@ -5015,12 +5015,12 @@ def mean_iou(input, label, num_classes):
50155015
out_correct = helper.create_tmp_variable(dtype='int32')
50165016
helper.append_op(
50175017
type="mean_iou",
5018-
inputs={"predictions": input,
5019-
"labels": label},
5018+
inputs={"Predictions": input,
5019+
"Labels": label},
50205020
outputs={
5021-
"out_mean_iou": out_mean_iou,
5022-
"out_wrong": out_wrong,
5023-
"out_correct": out_correct
5021+
"OutMeanIou": out_mean_iou,
5022+
"OutWrong": out_wrong,
5023+
"OutCorrect": out_correct
50245024
},
50255025
attrs={"num_classes": num_classes})
50265026
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)