def get_embedding():
embedding_path = os.path.join(FLAGS.datasets_dir, "wordVectors.txt")
if not tf.gfile.Exists(embedding_path):
raise ValueError("embedding file not exists")
# embedding = np.fromfile(embedding_path, sep=' ')
# print("embedding size:", embedding.shape)
# print("embedding size:", embedding.dtype)
# embedding.reshape(100232, 50)
# print("embedding size:", embedding.shape)
data = np.fromfile(embedding_path, dtype=np.float32, sep=' ')
print("shape:", data.shape)
print("ndim:", data.ndim)
print("dtype:", data.dtype)
print(data)
print("reshape vocabulary")
d = data.reshape((-1, 50))
print("shape:", d.shape)
print("ndim:", d.ndim)
print("dtype:", d.dtype)
print(d)
return d
评论列表
文章目录