【问题标题】:google::protobuf::TextFormat::Parse can't parse prototxt file successfullygoogle::protobuf::TextFormat::Parse 无法成功解析 prototxt 文件
【发布时间】:2018-09-22 09:38:56
【问题描述】:

我有一个求解器文件,如下所示。

train_net: "../Prototxtfiles/VGGNet/train.prototxt"
test_net: "../Prototxtfiles/VGGNet/test.prototxt"
test_iter: 172
test_interval: 1000
base_lr: 0.0010000000475
display: 10
max_iter: 30000
lr_policy: "multistep"
gamma: 0.10000000149
momentum: 0.899999976158
weight_decay: 0.000500000023749
snapshot: 5000
snapshot_prefix: "../Prototxtfiles/VGGNet/CROWDSENSING_SSD_500x500"
solver_mode: GPU
device_id: 0
debug_info: false
snapshot_after_train: true
test_initialization: false
average_loss: 10
stepvalue: 10000
stepvalue: 20000
stepvalue: 30000
iter_size: 4
type: "SGD"
eval_type: "detection"
ap_version: "11point"

我尝试使用下面的代码读取文件

bool ReadProtoFromTextFile(const char* filename, Message* proto) {
  int fd = open(filename, O_RDONLY);
  CHECK_NE(fd, -1) << "File not found: " << filename;
  google::protobuf::io::FileInputStream* input = new FileInputStream(fd);
  bool success = google::protobuf::TextFormat::Parse(input, proto);
  delete input;
  close(fd);
  return success;
}

我无法在 Windows 中解析,但它可以在 Linux 中使用。 可能是什么问题?

编辑:

可能是什么问题?我可以使用相同的代码读取这个 prototxt 文件。

net: "models/bvlc_googlenet/train_val.prototxt"
test_iter: 1000
test_interval: 4000
test_initialization: false
display: 40
average_loss: 40
base_lr: 0.01
lr_policy: "step"
stepsize: 320000
gamma: 0.96
max_iter: 10000000
momentum: 0.9
weight_decay: 0.0002
snapshot: 40000
snapshot_prefix: "models/bvlc_googlenet/bvlc_googlenet"
solver_mode: GPU

【问题讨论】:

  • 您到底遇到了什么错误?你为 Windows 编译了caffe.proto 吗?你能在windows上阅读其他prototxt文件吗?

标签: deep-learning protocol-buffers caffe


【解决方案1】:

如果你在Linux上可以解析,但在windows上不行,我会说你的问题是编码问题。

https://superuser.com/questions/294219/what-are-the-differences-between-linux-and-windows-txt-files-unicode-encoding

例如,如果您使用 Notepad++ 打开文件,您应该能够看到这些特殊字符。

在另一个线程上阅读,听起来像 TextFormat 只需要 UTF-8 编码的字符: What does the protobuf text format look like?

你如何构建你的 prototxt?

【讨论】:

    猜你喜欢
    • 2015-10-14
    • 1970-01-01
    • 1970-01-01
    • 2019-07-04
    • 1970-01-01
    • 1970-01-01
    • 2017-09-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多