inputs.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:text-classification2 作者: yuhui-lin 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号