1. 程式人生 > >關於google protocol buffer(PB)的優缺點和一些個人的理解

關於google protocol buffer(PB)的優缺點和一些個人的理解

--------------------------------
  網路名稱:name
  網路型別:type
  卷積層引數:convolution_param
--------------------------------
  如果使用protobuf實現,首先要寫一個proto檔案(不妨叫VGG.prototxt):
--------------------------------
layers{
  name: "conv2"
  type: CONVOLUTION
  convolution_param {
num_output: 192
kernel_size: 5
stride: 1
weight_filler {
 type: "xavier"
}
bias_filler {
 type: "constant"
 value: 0.1
}
  }
  bottom: "eltwise1"
  top: "conv2"
}
--------------------------------
接著利用protobuf內建的編譯器編譯這個檔案,重點可以看這個檔案solver.hpp。
有了protocol 我們就不用自己寫協議去解析這些檔案了,是不是很方便
還有一個好處是:如果通訊雙方使用不同的語言,使用protocol 可以有效確保兩邊的模組對於協議的處理是一致的。