INNER CODE UNIT · Python
test_custom_dense_layer_output
MITDeepLearning/introtodeeplearning · mitdeeplearning/lab1.py:107
def test_custom_dense_layer_output(y):
# define the ground truth value for the array
true_y = np.array([[0.27064407, 0.1826951, 0.50374055]], dtype="float32")
assert tf.shape(y).numpy().tolist() == list(
true_y.shape
), "[FAIL] output is of incorrect shape. expected {} but got {}".format(
true_y.shape, y.numpy().shape
)
np.testing.assert_almost_equal(
y.numpy(),
true_y,
decimal=7,
err_msg="[FAIL] output is of incorrect value. expected {} but got {}".format(
true_y, y.numpy()
),
verbose=True,
)
print("[PASS] test_custom_dense_layer_output")