test_common.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:keras-rcnn 作者: broadinstitute 项目源码 文件源码
def test_clip():
    boxes = numpy.array(
        [[0, 0, 0, 0], [1, 2, 3, 4], [-4, 2, 1000, 6000], [3, -10, 223, 224]])
    shape = [224, 224]
    boxes = keras.backend.variable(boxes)
    results = keras_rcnn.backend.clip(boxes, shape)
    results = keras.backend.eval(results)
    expected = numpy.array(
        [[0, 0, 0, 0], [1, 2, 3, 4], [0, 2, 223, 223], [3, 0, 223, 223]])
    numpy.testing.assert_array_almost_equal(results, expected)

    boxes = numpy.reshape(numpy.arange(200, 200 + 12 * 5), (-1, 12))
    shape = [224, 224]
    boxes = keras.backend.variable(boxes)
    results = keras_rcnn.backend.clip(boxes, shape)
    results = keras.backend.eval(results)
    expected = numpy.array(
        [[200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211],
         [212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223],
         [223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223],
         [223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223],
         [223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223]])
    numpy.testing.assert_array_almost_equal(results, expected, 0)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号