当前位置: 首页>>代码示例>>Python>>正文


Python testing.assert_tensor_equal函数代码示例

本文整理汇总了Python中neon.util.testing.assert_tensor_equal函数的典型用法代码示例。如果您正苦于以下问题:Python assert_tensor_equal函数的具体用法?Python assert_tensor_equal怎么用?Python assert_tensor_equal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了assert_tensor_equal函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_some_equal

 def test_some_equal(self):
     left = self.be.ones([2, 2])
     right = self.be.array([[0, 1], [0, 1]])
     out = self.be.empty([2, 2])
     self.be.equal(left, right, out)
     assert out.shape == (2, 2)
     assert_tensor_equal(out, CPUTensor([[0, 1], [0, 1]]))
开发者ID:AI-Cdrone,项目名称:neon,代码行数:7,代码来源:test_cpu.py

示例2: test_less_equal

 def test_less_equal(self):
     left = self.be.array([[-1, 0], [1, 92]])
     right = self.be.ones([2, 2])
     out = self.be.empty([2, 2])
     self.be.less_equal(left, right, out)
     assert out.shape == (2, 2)
     assert_tensor_equal(out, self.gpt([[1, 1], [1, 0]]))
开发者ID:AI-Cdrone,项目名称:neon,代码行数:7,代码来源:test_cc2.py

示例3: test_some_not_equal

 def test_some_not_equal(self):
     left = self.be.ones([2, 2])
     right = self.be.array([[0, 1], [0, 1]])
     out = self.be.empty([2, 2])
     self.be.not_equal(left, right, out)
     assert out.shape == (2, 2)
     assert_tensor_equal(out, self.gpt([[1, 0], [1, 0]]))
开发者ID:AI-Cdrone,项目名称:neon,代码行数:7,代码来源:test_cc2.py

示例4: test_all_not_equal

 def test_all_not_equal(self):
     left = self.be.ones([2, 2])
     right = self.be.zeros([2, 2])
     out = self.be.empty([2, 2])
     self.be.not_equal(left, right, out)
     assert out.shape == (2, 2)
     assert_tensor_equal(out, self.gpt([[1, 1], [1, 1]]))
开发者ID:AI-Cdrone,项目名称:neon,代码行数:7,代码来源:test_cc2.py

示例5: test_greater

 def test_greater(self):
     left = self.be.array([[-1, 0], [1, 92]])
     right = self.be.ones([2, 2])
     out = self.be.empty([2, 2])
     self.be.greater(left, right, out)
     assert out.shape == (2, 2)
     assert_tensor_equal(out, CPUTensor([[0, 0], [0, 1]]))
开发者ID:AI-Cdrone,项目名称:neon,代码行数:7,代码来源:test_cpu.py

示例6: test_none_not_equal

 def test_none_not_equal(self):
     left = self.be.ones([2, 2])
     right = self.be.ones([2, 2])
     out = self.be.empty([2, 2])
     self.be.not_equal(left, right, out)
     assert out.shape == (2, 2)
     assert_tensor_equal(out, CPUTensor([[0, 0], [0, 0]]))
开发者ID:AI-Cdrone,项目名称:neon,代码行数:7,代码来源:test_cpu.py

示例7: test_rectleaky_slope_zero_rectlin_equiv

def test_rectleaky_slope_zero_rectlin_equiv():
    be = CPU()
    inputs = be.uniform(low=-5.0, high=10.0, size=(10, 10))
    lin_buf = be.empty(inputs.shape)
    leaky_buf = be.empty(inputs.shape)
    be.rectlin(inputs, out=lin_buf)
    be.rectleaky(inputs, slope=0.0, out=leaky_buf)
    assert_tensor_equal(lin_buf, leaky_buf)
开发者ID:neuroidss,项目名称:neon,代码行数:8,代码来源:test_leaky.py

示例8: test_neginfnorm

 def test_neginfnorm(self):
     tsr = self.be.array([[-1, 0], [1, 3]])
     # -> min(abs(tsr), axis=0) -> [1, 0]
     assert_tensor_equal(self.be.norm(tsr, order=float('-inf'), axis=0),
                         CPUTensor([[1, 0]]))
     # -> min(abs(tsr), axis=1) -> [0, 1]
     assert_tensor_equal(self.be.norm(tsr, order=float('-inf'), axis=1),
                         CPUTensor([0, 1]))
开发者ID:AI-Cdrone,项目名称:neon,代码行数:8,代码来源:test_cpu.py

示例9: test_range_slicing

 def test_range_slicing(self):
     tns = CPUTensor([[1, 2], [3, 4]])
     res = tns[0:2, 0]
     expected_shape = (2, )
     while len(expected_shape) < res._min_dims:
         expected_shape += (1, )
     assert res.shape == expected_shape
     assert_tensor_equal(res, CPUTensor([1, 3]))
开发者ID:AI-Cdrone,项目名称:neon,代码行数:8,代码来源:test_cputensor.py

示例10: test_infnorm

 def test_infnorm(self):
     tsr = self.be.array([[-1, 0], [1, 3]])
     # -> max(abs(tsr), axis=0) -> [1, 3]
     assert_tensor_equal(self.be.norm(tsr, order=float('inf'), axis=0),
                         CPUTensor([[1, 3]]))
     # -> max(abs(tsr), axis=1) -> [1, 3]
     assert_tensor_equal(self.be.norm(tsr, order=float('inf'), axis=1),
                         CPUTensor([1, 3]))
开发者ID:AI-Cdrone,项目名称:neon,代码行数:8,代码来源:test_cpu.py

示例11: test_0norm

 def test_0norm(self):
     tsr = self.be.array([[-1, 0], [1, 3]])
     # -> sum(tsr != 0, axis=0) -> [2, 1]
     assert_tensor_equal(self.be.norm(tsr, order=0, axis=0),
                         CPUTensor([[2, 1]]))
     # -> sum(tsr != 0, axis=1) -> [1, 2]
     assert_tensor_equal(self.be.norm(tsr, order=0, axis=1),
                         CPUTensor([1, 2]))
开发者ID:AI-Cdrone,项目名称:neon,代码行数:8,代码来源:test_cpu.py

示例12: test_1norm

 def test_1norm(self):
     tsr = self.be.array([[-1, 0], [1, 3]])
     # -> sum([[1, 0], [1, 3]], axis=0)**1 -> [2, 3]
     assert_tensor_equal(self.be.norm(tsr, order=1, axis=0),
                         CPUTensor([[2, 3]]))
     # -> sum([[1, 0], [1, 3]], axis=1)**1 -> [1, 4]
     assert_tensor_equal(self.be.norm(tsr, order=1, axis=1),
                         CPUTensor([1, 4]))
开发者ID:AI-Cdrone,项目名称:neon,代码行数:8,代码来源:test_cpu.py

示例13: test_2norm

 def test_2norm(self):
     tsr = self.be.array([[-1, 0], [1, 3]])
     rpow = 1. / 2
     # -> sum([[1, 0], [1, 9]], axis=0)**.5 -> sqrt([2, 9])
     assert_tensor_equal(self.be.norm(tsr, order=2, axis=0),
                         CPUTensor([[2**rpow, 9**rpow]]))
     # -> sum([[1, 0], [1, 9]], axis=1)**.5 -> sqrt([1, 10])
     assert_tensor_equal(self.be.norm(tsr, order=2, axis=1),
                         CPUTensor([1**rpow, 10**rpow]))
开发者ID:AI-Cdrone,项目名称:neon,代码行数:9,代码来源:test_cpu.py

示例14: test_cc2_rectleaky_derivative_slope_zero_rectlin_equiv

def test_cc2_rectleaky_derivative_slope_zero_rectlin_equiv():
    from neon.backends.cc2 import GPU
    be = GPU()
    inputs = be.uniform(low=-5.0, high=10.0, size=(10, 10))
    lin_buf = be.empty(inputs.shape)
    leaky_buf = be.empty(inputs.shape)
    be.rectlin_derivative(inputs, out=lin_buf)
    be.rectleaky_derivative(inputs, slope=0.0, out=leaky_buf)
    assert_tensor_equal(lin_buf, leaky_buf)
开发者ID:neuroidss,项目名称:neon,代码行数:9,代码来源:test_leaky.py

示例15: compare_cpu_tensors

def compare_cpu_tensors(inputs, outputs, deriv=False):
    rlin = RectLeaky()
    be = CPU()
    temp = be.zeros(inputs.shape)
    if deriv is True:
        rlin.apply_derivative(be, CPUTensor(inputs), temp)
    else:
        rlin.apply_function(be, CPUTensor(inputs), temp)
    be.subtract(temp, CPUTensor(outputs), temp)
    assert_tensor_equal(temp, be.zeros(inputs.shape))
开发者ID:neuroidss,项目名称:neon,代码行数:10,代码来源:test_leaky.py


注:本文中的neon.util.testing.assert_tensor_equal函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。