コード例 #1
0
 def test_create_vocabulary(self):
     voc2 = Vocabulary.create_vocabulary(["a", "b", "a", "c"],
                                         0,
                                         create_one_hot_embeddings=True)
     vectors2 = np.array([
         [1, 0, 0, 0],
         [0, 1, 0, 0],
         [0, 0, 1, 0],
         [0, 0, 0, 1],
     ])
     with tf.Session() as sess:
         self.assertTrue(
             (sess.run(voc2.get_lookup_tensor()) == vectors2).all())
     self.assertTrue((voc2.word2vec("newword") == np.array([1, 0, 0,
                                                            0])).all())