Exemple #1
0
def compare_cpu_tensors(inputs, outputs, deriv=False):
    rlin = RectLin()
    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))
Exemple #2
0
def compare_cc2_tensors(inputs, outputs, deriv=False):
    from neon.backends.cc2 import GPU, GPUTensor
    rlin = RectLin()
    be = GPU()
    temp = be.zeros(inputs.shape)
    if deriv is True:
        rlin.apply_derivative(be, GPUTensor(inputs), temp)
    else:
        rlin.apply_function(be, GPUTensor(inputs), temp)
    be.subtract(temp, GPUTensor(outputs), temp)
    assert_tensor_equal(temp, be.zeros(inputs.shape))