def test_logistic_derivative_cputensor(): lgstc = Logistic() inputs = np.array([0, 1, -2]).reshape((3, 1)) be = CPU(rng_seed=0) outputs = 1.0 / (1.0 + np.exp(-inputs)) outputs = outputs * (1.0 - outputs) temp = be.zeros(inputs.shape) lgstc.apply_derivative(be, CPUTensor(inputs), temp) assert_tensor_near_equal(CPUTensor(outputs), temp)
def test_logistic_derivative_cc2tensor(): lgstc = Logistic() from neon.backends.cc2 import GPU, GPUTensor inputs = np.array([0, 1, -2]).reshape((3, 1)) outputs = 1.0 / (1.0 + np.exp(-inputs)) outputs = outputs * (1.0 - outputs) be = GPU(rng_seed=0) temp = be.zeros(inputs.shape) lgstc.apply_derivative(be, GPUTensor(inputs), temp) assert_tensor_near_equal(GPUTensor(outputs), temp)