예제 #1
0
def test_suggested_sigma(sess):
    data = np.arange(25, dtype=float).reshape((5, 5))
    data = tf.convert_to_tensor(data, dtype=tf.float32)

    s_sigma = sess.run(mvsc.suggested_sigma(data))

    real_s_sigma = 7.0

    array_eq(s_sigma, real_s_sigma, decimal=4)
예제 #2
0
def test_mvmds_multiple(sess, data, is_distance, k, real_result):
    data_tf = tf.convert_to_tensor(data, dtype=tf.float32)

    result = sess.run(mvmds.mvmds(data_tf, is_distance, k=2))

    from multiview.mvmds import mvmds as mds_cpu
    print("Multiview Result")
    np.set_printoptions(precision=10, suppress=True)
    print(mds_cpu(data, is_distance, k=k))

    array_eq(np.abs(result[:, 0]), np.abs(real_result[:, 0]), decimal=4)
예제 #3
0
def test_gaussian_similarity(sess):
    data = np.arange(25, dtype=float).reshape((5, 5))
    data = tf.convert_to_tensor(data, dtype=tf.float32)

    similarity = sess.run(mvsc.distance_gaussian_similarity(data, 2))

    real_similarity = np.array([[1., 0.8824, 0.6065, 0.3246, 0.1353],
                                [0.0439, 0.0110, 0.0021, 0.0003, 0.],
                                [0., 0., 0., 0., 0.], [0., 0., 0., 0., 0.],
                                [0., 0., 0., 0., 0.]])

    array_eq(similarity, real_similarity, decimal=4)
예제 #4
0
def test_laplacian_ng(sess):
    data = np.arange(25, dtype=float).reshape((5, 5))
    data = tf.convert_to_tensor(data, dtype=tf.float32)

    laplacian = sess.run(mvsc.laplacian_ng(data))

    real_laplacian = np.array([[0., 0.0534, 0.0816, 0.1028, 0.1206],
                               [0.2672, 0.1714, 0.1527, 0.1466, 0.1450],
                               [0.4082, 0.2400, 0.2, 0.1820, 0.1723],
                               [0.5144, 0.2933, 0.2380, 0.2117, 0.1964],
                               [0.6030, 0.3384, 0.2708, 0.2378, 0.2181]])

    array_eq(laplacian, real_laplacian, decimal=4)
예제 #5
0
def test_preprocess_mds(sess):
    data = np.arange(25, dtype=float).reshape((5, 5))
    data = tf.convert_to_tensor(data, dtype=tf.float32)

    preprocessed_data = sess.run(mvmds.preprocess_mvmds(data))

    sim = np.array([[40., 20., 0., -20., -40.],
                    [20., 10., 0., -10., -20.],
                    [0., 0., 0., 0., 0.],
                    [-20., -10., 0., 10., 20.],
                    [-40., -20., 0., 20., 40.]])

    array_eq(preprocessed_data, sim, decimal=4)
예제 #6
0
def test_mvsc_multiple(sess, data, is_distance, k, real_clust, real_evalues,
                       real_evectors, real_sigmas):
    data_tf = tf.convert_to_tensor(data, dtype=tf.float64)

    result = sess.run(mvsc.mvsc(data_tf, is_distance, k=k))
    (clust, evalues, evectors, sigmas) = result

    # from multiview.mvsc import mvsc as sc_cpu
    # print("Multiview Result")
    # np.set_printoptions(precision=10, suppress=True)
    # print(sc_cpu(data, is_distance, k=k))

    array_eq(normalize_labels(clust), normalize_labels(real_clust), decimal=4)
    array_eq(evalues, real_evalues, decimal=4)
    array_eq(np.abs(evectors), np.abs(real_evectors), decimal=4)
    array_eq(sigmas, real_sigmas, decimal=4)
예제 #7
0
 def validateEval(self, a, b, Z, L, J, Y, dx, dy, dz):
     array_eq(a + Z.dot(dx) + L.dot(abs(dz)), dz)
     array_eq(b + J.dot(dx) + Y.dot(abs(dz)), dy)