test_basic.py 文件源码

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

项目:Theano-Deep-learning 作者: GeekLiB 项目源码 文件源码
def test_tensor_values_eq_approx():
    # test, inf, -inf and nan equal themself
    a = numpy.asarray([-numpy.inf, -1, 0, 1, numpy.inf, numpy.nan])
    assert TensorType.values_eq_approx(a, a)

    # test inf, -inf don't equal themself
    b = numpy.asarray([numpy.inf, -1, 0, 1, numpy.inf, numpy.nan])
    assert not TensorType.values_eq_approx(a, b)
    b = numpy.asarray([-numpy.inf, -1, 0, 1, -numpy.inf, numpy.nan])
    assert not TensorType.values_eq_approx(a, b)

    # test allow_remove_inf
    b = numpy.asarray([numpy.inf, -1, 0, 1, 5, numpy.nan])
    assert TensorType.values_eq_approx(a, b, allow_remove_inf=True)
    b = numpy.asarray([numpy.inf, -1, 0, 1, 5, 6])
    assert not TensorType.values_eq_approx(a, b, allow_remove_inf=True)

    # test allow_remove_nan
    b = numpy.asarray([numpy.inf, -1, 0, 1, 5, numpy.nan])
    assert not TensorType.values_eq_approx(a, b, allow_remove_nan=False)
    b = numpy.asarray([-numpy.inf, -1, 0, 1, numpy.inf, 6])
    assert not TensorType.values_eq_approx(a, b, allow_remove_nan=False)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号