美文网首页
提取checkpoint中的tensor

提取checkpoint中的tensor

作者: Nevrast | 来源:发表于2020-06-17 11:19 被阅读0次
    # 从ckpt文件读入模型参数
    reader = tf.train.NewCheckpointReader(model_path)
    # 获取变量列表
    var_dict = reader.get_variable_to_dtype_map()
    # 从列表里面选择想要保存的variable
    tensor = reader.get_tensor('bert/embeddings/word_embeddings')
    tensor.shape  # (21128, 128)
    

    然后使用np.savetxt之类的方法存到文件里。

    相关文章

      网友评论

          本文标题:提取checkpoint中的tensor

          本文链接:https://www.haomeiwen.com/subject/jxzplhtx.html