コード例 #1
0
    def test__initialize_params_(self):
        preheated_embeddings = np.array([
            np.array([-1.0, -1.0, -6.0]),
            np.array([-1.0, -1.0, 5.0]),
            np.array([-1.0, -1.0, 4.0]),
            np.array([-1.0, 3.0, -1.0]),
            np.array([1.0, 1.0, -1.0]),
            np.array([2.0, 1.0, -1.0]),
            np.array([1.0, -1.0, 1.0]),
            np.array([1.0, -1.0, -1.0])
        ])

        interaction_sparse_tensor = interaction_map.idxs_to_tf([2])

        test_netowrk = Network(cf, interaction_map, preheated_embeddings)

        with tf.Session() as sess:
            sess.run(tf.global_variables_initializer())
            result = sess.run(
                test_netowrk.embedd_interaction_sparse_tensor(
                    interaction_sparse_tensor))

        np.testing.assert_array_equal(result, [[-1.0, -1.0, 4.0]])