Beispiel #1
0
def test_part_c():
    data = np.loadtxt('data/data.asc').T.reshape(1, 24, -1)
    cnn = cnn_solution.CNN_C()
    weights = np.load('weights/mlp_weights_part_c.npy')
    cnn.init_weights(weights)

    expected_result = np.load('autograde/res_c.npy')
    result = cnn(data)

    try:
        assert(type(result)==type(expected_result))
        assert(result.shape==expected_result.shape)
        assert(np.allclose(result,expected_result))

        return True
    except Exception as e:
        traceback.print_exc()
        return False
def test_part_c():
    data = np.loadtxt('data/data.asc').T.reshape(1, 24, -1)
    cnn = cnn_solution.CNN_C()
    weights = np.load('weights/mlp_weights_part_c.npy', allow_pickle=True)
    cnn.init_weights(weights)

    expected_result = np.load('autograde/res_c.npy')
    result = cnn(data)

    try:
        assert (type(result) == type(expected_result))
        assert (
            result.shape == expected_result.shape
        ), "result: {}, expected: {}  \n*********expected_Result************\n{}".format(
            result.shape, expected_result.shape, expected_result)
        assert (
            np.allclose(result, expected_result)
        ), "\n***********result*************\n{}, \n*********expected_Result************\n{}".format(
            result, expected_result)

        return True
    except Exception as e:
        traceback.print_exc()
        return False