In a caffe.proto file, What's the different between "optional" and "repeated" in message struct ?

17 views
Skip to first unread message

Le Xuan Tuan Anh

unread,
Jan 18, 2018, 1:46:59 AM1/18/18
to Caffe Users
Hi everyone
When I build caffe on Windows by VS2015, I realize in a message struct (in a src/proto/caffe.proto file) if the option is "repeated" , Visual Studio will make a function/parameter such "void add_your_parameter(::google::protobuf::uint32 value);" in a caffe.pb.h file, and if the option is "optional", there will not make a "add_......." function 
Question is What's the mean of that different ?

example:
message PowerParameter {
  // PowerLayer computes outputs y = (shift + scale * x) ^ power.
  optional float power = 1 [default = 1.0];
  repeated float scale = 2 [default = 1.0];
  optional float shift = 3 [default = 0.0];
}

Windows 10
Visual Studio Update 3
CPU

Przemek D

unread,
Jan 19, 2018, 6:24:07 AM1/19/18
to Caffe Users
This is not actually done by Visual Studio (nor the MSVC compiler, to be exact) but by the Google Protocol Buffer (protobuf) compiler.
Meaning, in short, is that repeated fields can be supplied multiple times (eg. you can have several params within a single layer, but only one name), so the add function, I presume, allows you to set another one. There is no need for that in an optional field, which can only be or not be present.
Reply all
Reply to author
Forward
0 new messages