【问题标题】:How to read NetParameter from H5 trained model in C++ or Python in Caffe library?如何从 Caffe 库中的 C++ 或 Python 中的 H5 训练模型中读取 NetParameter?
【发布时间】:2023-04-10 04:27:01
【问题描述】:

我喜欢加载经过训练的二进制文件并打印到文本文件中。

我们可以在C++ from caffemodel normally in binary protobuf format中读取训练好的参数。

我是怎么做的,

net_.reset(new Net<float>(model_file, TEST));
    NetParameter param;

ReadNetParamsFromBinaryFileOrDie(trained_file_protobuf, &param);
WriteProtoToTextFile(param, "model_protobuf.txt");

但一些经过训练的模型以 h5 格式提供,以及如何加载文件并打印到 C++ 或 Python 中的文本文件。

net.cpp 中,我找不到ReadNetParamsFromBinaryFileOrDie 的h5 格式。 ReadNetParamsFromBinaryFileOrDie 代表binary protobuf format

如何从经过训练的 H5 模型中读取 NetParameter 并打印到文本文件?

【问题讨论】:

    标签: neural-network deep-learning caffe pycaffe


    【解决方案1】:

    你看过CopyTrainedLayersFromHDF5Net的一个方法)吗?
    应该是这样的:

    net_.reset(new Net<float>(model_file, TEST));
    net_.CopyTrainedLayersFromHDF5(trained_file_h5);
    

    【讨论】:

      猜你喜欢
      • 2017-07-09
      • 2017-03-16
      • 2015-11-28
      • 1970-01-01
      • 2019-06-27
      • 1970-01-01
      • 2015-07-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多