def test_relu_1(self): input = np.array([[2, 3, 5, 1, 7], [4, 3, 0, 5, 5], [-1, 2, 0, -3, -4]]) output = np.array([[2, 3, 5, 1, 7], [4, 3, 0, 5, 5], [0, 2, 0, 0, 0]]) np.testing.assert_allclose(util_functions.relu(input), output, atol=0.0001)
def test_linear_with_relu_2(self): x = np.array([[1, 2, 0, -1], [1, 2, 33, 15]]) w = np.array([[0., 1., 0., 0.], [0., 2., 2., 0.]]) b = np.array([-5., -1.]) expected_res = np.array([[0., 3.], [0., 69.]]) np.testing.assert_allclose(util_functions.relu( util_functions.linear(x, w, b)), expected_res, atol=0.0001)
def test_linear_with_relu_1(self): x = np.array([[1, 2, 33, 15], [1, 2, 33, 15]]) w = np.array([[0., 1., 0., 0.], [0., 2., 2., 0.]]) b = np.zeros(2) expected_res = np.array([[2., 70.], [2., 70.]]) np.testing.assert_allclose(util_functions.relu( util_functions.linear(x, w, b)), expected_res, atol=0.0001)
def __call__(self, z): self.layer_input = z self.layer_output = util_functions.relu(z) return self.layer_output
def relu_function(x): return np.sum( util_functions.relu(x)), util_functions.relu_derivative(x)
def test_relu_3(self): input = np.array([-2, -3, 5, 1, 7]) output = np.array([0, 0, 5, 1, 7]) np.testing.assert_allclose(util_functions.relu(input), output, atol=0.0001)