Skip to content

Commit

Permalink
Unify the metrics implementation between low-level and high-level API. (
Browse files Browse the repository at this point in the history
#26158)

* Move paddle/incubate/hapi/metrics to paddle/metric
* Add Precision, Recall and Auc metric
  • Loading branch information
qingqing01 authored Aug 24, 2020
1 parent da1efe2 commit 78ca8cf
Show file tree
Hide file tree
Showing 16 changed files with 1,164 additions and 533 deletions.
1 change: 1 addition & 0 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ set(PADDLE_PYTHON_PACKAGE_DIR ${CMAKE_CURRENT_BINARY_DIR}/dist/)
if (WITH_TESTING)
add_subdirectory(paddle/reader/tests)
add_subdirectory(paddle/dataset/tests)
add_subdirectory(paddle/tests)
add_subdirectory(paddle/fluid/tests)
add_subdirectory(paddle/fluid/contrib/tests)
add_subdirectory(paddle/fluid/contrib/slim/tests)
Expand Down
27 changes: 27 additions & 0 deletions python/paddle/fluid/tests/unittests/test_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3682,5 +3682,32 @@ def test_basic_gru(self):
batch_first=batch_first)


class TestMetricsDetectionMap(unittest.TestCase):
def test_detection_map(self):
program = fluid.Program()
with program_guard(program):
detect_res = fluid.layers.data(
name='detect_res',
shape=[10, 6],
append_batch_size=False,
dtype='float32')
label = fluid.layers.data(
name='label',
shape=[10, 1],
append_batch_size=False,
dtype='float32')
box = fluid.layers.data(
name='bbox',
shape=[10, 4],
append_batch_size=False,
dtype='float32')
map_eval = fluid.metrics.DetectionMAP(
detect_res, label, box, class_num=21)
cur_map, accm_map = map_eval.get_map_var()
self.assertIsNotNone(cur_map)
self.assertIsNotNone(accm_map)
print(str(program))


if __name__ == '__main__':
unittest.main()
49 changes: 0 additions & 49 deletions python/paddle/fluid/tests/unittests/test_metrics.py

This file was deleted.

2 changes: 0 additions & 2 deletions python/paddle/incubate/hapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from . import model
from .model import *

from . import metrics
from . import datasets
from . import distributed
from . import vision
Expand All @@ -39,7 +38,6 @@
'datasets',
'distributed',
'download',
'metrics',
'vision',
'text',
'utils',
Expand Down
8 changes: 4 additions & 4 deletions python/paddle/incubate/hapi/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ class ProgBarLogger(Callback):
optim = fluid.optimizer.Adam(0.001)
model.prepare(optimizer=optim,
loss_function=paddle.nn.CrossEntropyLoss(),
metrics=hapi.metrics.Accuracy())
loss=paddle.nn.CrossEntropyLoss(),
metrics=paddle.metric.Accuracy())
callback = hapi.callbacks.ProgBarLogger(log_freq=10)
model.fit(train_dataset, batch_size=64, callbacks=callback)
Expand Down Expand Up @@ -441,8 +441,8 @@ class ModelCheckpoint(Callback):
optim = fluid.optimizer.Adam(0.001)
model.prepare(optimizer=optim,
loss_function=paddle.nn.CrossEntropyLoss(),
metrics=hapi.metrics.Accuracy())
loss=paddle.nn.CrossEntropyLoss(),
metrics=paddle.metric.Accuracy())
callback = hapi.callbacks.ModelCheckpoint(save_dir='./temp')
model.fit(train_dataset, batch_size=64, callbacks=callback)
Expand Down
233 changes: 0 additions & 233 deletions python/paddle/incubate/hapi/metrics.py

This file was deleted.

Loading

0 comments on commit 78ca8cf

Please sign in to comment.