适合女生的笔记本电脑如何打开235&PROTO=HTTP类型的文件

【Protobuf】
Protobuf是谷歌出的一款协议,利用它可以方便地进行数据传输。
在互联网上用于数据传输的格式还包括xml和json.
如何使用(以Java为例)
到谷歌开发者官网上下载protoc.exe文件用于编译原始的protobuf文件.
将原始的proto文件放在与protoc.exe同级的目录下.
在NotePad++中打开proto文件,修改package为java文件将要放置的包中。然后将其转为UTF-8 无BOM编码格式(否则生成的java文件可能会出现乱码)。
在命令行下进入protoc.exe所在目录敲以下命令:
protoc.exe[空格]–java_out=./[空格]xxx.proto
将生成的java文件放在项目中即可
没有更多推荐了,  由于业务需要,接触caffe已经有接近半年,一直忙着阅读各种论文,重现大大小小的模型. 期间也总结过一些caffe源码学习笔记,断断续续,这次打算系统的记录一下caffe源码学习笔记,巩固一下C++,同时也梳理一下自己之前的理解。
  我们先不看caffe的框架结构,先介绍一下caffe.proto,是google开源的一种数据交互格式--Google&Protobuf,这种数据的格式,我们可以看到caffe.proto中内容:
syntax = "proto2";
 //caffe.prto中的各个结构封装在caffe包中,可以通过u 或者caffe::** 调用
// Specifies the shape (dimensions) of a Blob.
message BlobShape {
repeated int64 dim = 1 [packed = true];
message BlobProto {
optional BlobShape shape = 7;
repeated float data = 5 [packed = true];
repeated float diff = 6 [packed = true];
repeated double double_data = 8 [packed = true];
repeated double double_diff = 9 [packed = true];
// 4D dimensions -- deprecated.
Use "shape" instead.
optional int32 num = 1 [default = 0];
optional int32 channels = 2 [default = 0];
optional int32 height = 3 [default = 0];
optional int32 width = 4 [default = 0];
当我们在编译完成caffe之后,会自动在src/caffe/proto中生成两个文件caffe.pb.h 和caffe.pb.cc
那么这种数据格式在程序中是如何被使用的呢? 我们举一个简单的例子,来演示caffe.proto生成caffe.pb.h和caffe.pb.cc以及被调用的过程
如果你之前能够编译caffe成功,则说明你已经成功安装了Protobuf,那么我简单的编写一个使用Protobuf的例子吧.
我们先编写一个文件caffe.proto:
message student
required int32 age = 1; //ID required 表示必要字段
required string name = 2; //str 必要字段
optional int32 grade = 3 ; //optional field 可选字段,可以有无,最多b
然后我们执行如下操作。
protoc -I=. --cpp_out=. ./caffe.proto
protobuf会自动生成.cc和.h文件
1 // Generated by the protocol buffer compiler.
DO NOT EDIT!
2 // source: caffe.proto
4 #ifndef PROTOBUF_caffe_2eproto__INCLUDED
5 #define PROTOBUF_caffe_2eproto__INCLUDED
7 #include &string&
9 #include &google/protobuf/stubs/common.h&
11 #if GOOGLE_PROTOBUF_VERSION & 2005000
12 #error This file was generated by a newer version of protoc which is
13 #error incompatible with your Protocol Buffer headers.
Please update
14 #error your headers.
16 #if 2005000 & GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
17 #error This file was generated by an older version of protoc which is
18 #error incompatible with your Protocol Buffer headers.
19 #error regenerate this file with a newer version of protoc.
22 #include &google/protobuf/generated_message_util.h&
23 #include &google/protobuf/message.h&
24 #include &google/protobuf/repeated_field.h&
25 #include &google/protobuf/extension_set.h&
26 #include &google/protobuf/unknown_field_set.h&
27 // @@protoc_insertion_point(includes)
29 namespace caffe {
31 // Internal implementation detail -- do not call these.
protobuf_AddDesc_caffe_2eproto();
33 void protobuf_AssignDesc_caffe_2eproto();
34 void protobuf_ShutdownFile_caffe_2eproto();
38 // ===================================================================
40 class student : public ::google::protobuf::Message {
student();
virtual ~student();
student(const student& from);
inline student& operator=(const student& from) {
CopyFrom(from);
return *this;
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
static const ::google::protobuf::Descriptor* descriptor();
static const student& default_instance();
void Swap(student* other);
// implements Message ----------------------------------------------
student* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const student& from);
void MergeFrom(const student& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// required int32 age = 1;
inline bool has_age() const;
inline void clear_age();
static const int kAgeFieldNumber = 1;
inline ::google::protobuf::int32 age() const;
inline void set_age(::google::protobuf::int32 value);
// required string name = 2;
inline bool has_name() const;
inline void clear_name();
static const int kNameFieldNumber = 2;
inline const ::std::string& name() const;
inline void set_name(const ::std::string& value);
inline void set_name(const char* value);
inline void set_name(const char* value, size_t size);
inline ::std::string* mutable_name();
inline ::std::string* release_name();
inline void set_allocated_name(::std::string* name);
// optional int32 grade = 3;
inline bool has_grade() const;
inline void clear_grade();
static const int kGradeFieldNumber = 3;
inline ::google::protobuf::int32 grade() const;
inline void set_grade(::google::protobuf::int32 value);
// @@protoc_insertion_point(class_scope:caffe.student)
inline void set_has_age();
inline void clear_has_age();
inline void set_has_name();
inline void clear_has_name();
inline void set_has_grade();
inline void clear_has_grade();
::google::protobuf::UnknownFieldSet _unknown_fields_;
::std::string* name_;
::google::protobuf::int32 age_;
::google::protobuf::int32 grade_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(3 + 31) / 32];
friend void
protobuf_AddDesc_caffe_2eproto();
friend void protobuf_AssignDesc_caffe_2eproto();
friend void protobuf_ShutdownFile_caffe_2eproto();
void InitAsDefaultInstance();
static student* default_instance_;
145 // ===================================================================
148 // ===================================================================
150 // student
152 // required int32 age = 1;
153 inline bool student::has_age() const {
return (_has_bits_[0] & 0xu) != 0;
156 inline void student::set_has_age() {
_has_bits_[0] |= 0xu;
159 inline void student::clear_has_age() {
_has_bits_[0] &= ~0xu;
162 inline void student::clear_age() {
clear_has_age();
166 inline ::google::protobuf::int32 student::age() const {
return age_;
169 inline void student::set_age(::google::protobuf::int32 value) {
set_has_age();
174 // required string name = 2;
175 inline bool student::has_name() const {
return (_has_bits_[0] & 0xu) != 0;
178 inline void student::set_has_name() {
_has_bits_[0] |= 0xu;
181 inline void student::clear_has_name() {
_has_bits_[0] &= ~0xu;
184 inline void student::clear_name() {
if (name_ != &::google::protobuf::internal::kEmptyString) {
name_-&clear();
clear_has_name();
190 inline const ::std::string& student::name() const {
return *name_;
193 inline void student::set_name(const ::std::string& value) {
set_has_name();
if (name_ == &::google::protobuf::internal::kEmptyString) {
name_ = new ::std::string;
name_-&assign(value);
200 inline void student::set_name(const char* value) {
set_has_name();
if (name_ == &::google::protobuf::internal::kEmptyString) {
name_ = new ::std::string;
name_-&assign(value);
207 inline void student::set_name(const char* value, size_t size) {
set_has_name();
if (name_ == &::google::protobuf::internal::kEmptyString) {
name_ = new ::std::string;
name_-&assign(reinterpret_cast&const char*&(value), size);
214 inline ::std::string* student::mutable_name() {
set_has_name();
if (name_ == &::google::protobuf::internal::kEmptyString) {
name_ = new ::std::string;
return name_;
221 inline ::std::string* student::release_name() {
clear_has_name();
if (name_ == &::google::protobuf::internal::kEmptyString) {
return NULL;
::std::string* temp = name_;
name_ = const_cast& ::std::string*&(&::google::protobuf::internal::kEmptyString);
231 inline void student::set_allocated_name(::std::string* name) {
if (name_ != &::google::protobuf::internal::kEmptyString) {
delete name_;
if (name) {
set_has_name();
clear_has_name();
name_ = const_cast& ::std::string*&(&::google::protobuf::internal::kEmptyString);
244 // optional int32 grade = 3;
245 inline bool student::has_grade() const {
return (_has_bits_[0] & 0xu) != 0;
248 inline void student::set_has_grade() {
_has_bits_[0] |= 0xu;
251 inline void student::clear_has_grade() {
_has_bits_[0] &= ~0xu;
254 inline void student::clear_grade() {
grade_ = 0;
clear_has_grade();
258 inline ::google::protobuf::int32 student::grade() const {
return grade_;
261 inline void student::set_grade(::google::protobuf::int32 value) {
set_has_grade();
267 // @@protoc_insertion_point(namespace_scope)
// namespace caffe
271 #ifndef SWIG
272 namespace google {
273 namespace protobuf {
// namespace google
// namespace protobuf
278 #endif
280 // @@protoc_insertion_point(global_scope)
282 #endif
// PROTOBUF_caffe_2eproto__INCLUDED
caffe.pb.h
1 // Generated by the protocol buffer compiler.
DO NOT EDIT!
2 // source: caffe.proto
4 #define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
5 #include "caffe.pb.h"
7 #include &algorithm&
9 #include &google/protobuf/stubs/common.h&
10 #include &google/protobuf/stubs/once.h&
11 #include &google/protobuf/io/coded_stream.h&
12 #include &google/protobuf/wire_format_lite_inl.h&
13 #include &google/protobuf/descriptor.h&
14 #include &google/protobuf/generated_message_reflection.h&
15 #include &google/protobuf/reflection_ops.h&
16 #include &google/protobuf/wire_format.h&
17 // @@protoc_insertion_point(includes)
19 namespace caffe {
21 namespace {
23 const ::google::protobuf::Descriptor* student_descriptor_ = NULL;
24 const ::google::protobuf::internal::GeneratedMessageReflection*
student_reflection_ = NULL;
// namespace
30 void protobuf_AssignDesc_caffe_2eproto() {
protobuf_AddDesc_caffe_2eproto();
const ::google::protobuf::FileDescriptor* file =
::google::protobuf::DescriptorPool::generated_pool()-&FindFileByName(
"caffe.proto");
GOOGLE_CHECK(file != NULL);
student_descriptor_ = file-&message_type(0);
static const int student_offsets_[3] = {
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(student, age_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(student, name_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(student, grade_),
student_reflection_ =
new ::google::protobuf::internal::GeneratedMessageReflection(
student_descriptor_,
student::default_instance_,
student_offsets_,
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(student, _has_bits_[0]),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(student, _unknown_fields_),
::google::protobuf::DescriptorPool::generated_pool(),
::google::protobuf::MessageFactory::generated_factory(),
sizeof(student));
55 namespace {
57 GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);
58 inline void protobuf_AssignDescriptorsOnce() {
::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,
&protobuf_AssignDesc_caffe_2eproto);
63 void protobuf_RegisterTypes(const ::std::string&) {
protobuf_AssignDescriptorsOnce();
::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
student_descriptor_, &student::default_instance());
// namespace
71 void protobuf_ShutdownFile_caffe_2eproto() {
delete student::default_instance_;
delete student_reflection_;
76 void protobuf_AddDesc_caffe_2eproto() {
static bool already_here = false;
if (already_here) return;
already_here = true;
GOOGLE_PROTOBUF_VERIFY_VERSION;
::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
"\n\013caffe.proto\022\005caffe\"3\n\007student\022\013\n\003age\030\001"
" \002(\005\022\014\n\004name\030\002 \002(\t\022\r\n\005grade\030\003 \001(\005", 73);
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
"caffe.proto", &protobuf_RegisterTypes);
student::default_instance_ = new student();
student::default_instance_-&InitAsDefaultInstance();
::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_caffe_2eproto);
92 // Force AddDescriptors() to be called at static initialization time.
93 struct StaticDescriptorInitializer_caffe_2eproto {
StaticDescriptorInitializer_caffe_2eproto() {
protobuf_AddDesc_caffe_2eproto();
97 } static_descriptor_initializer_caffe_2eproto_;
99 // ===================================================================
101 #ifndef _MSC_VER
102 const int student::kAgeFieldN
103 const int student::kNameFieldN
104 const int student::kGradeFieldN
105 #endif
// !_MSC_VER
107 student::student()
: ::google::protobuf::Message() {
SharedCtor();
112 void student::InitAsDefaultInstance() {
115 student::student(const student& from)
: ::google::protobuf::Message() {
SharedCtor();
MergeFrom(from);
121 void student::SharedCtor() {
_cached_size_ = 0;
name_ = const_cast& ::std::string*&(&::google::protobuf::internal::kEmptyString);
grade_ = 0;
::memset(_has_bits_, 0, sizeof(_has_bits_));
129 student::~student() {
SharedDtor();
133 void student::SharedDtor() {
if (name_ != &::google::protobuf::internal::kEmptyString) {
delete name_;
if (this != default_instance_) {
141 void student::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ =
GOOGLE_SAFE_CONCURRENT_WRITES_END();
146 const ::google::protobuf::Descriptor* student::descriptor() {
protobuf_AssignDescriptorsOnce();
return student_descriptor_;
151 const student& student::default_instance() {
if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto();
return *default_instance_;
156 student* student::default_instance_ = NULL;
158 student* student::New() const {
return new
162 void student::Clear() {
if (_has_bits_[0 / 32] & (0xffu && (0 % 32))) {
if (has_name()) {
if (name_ != &::google::protobuf::internal::kEmptyString) {
name_-&clear();
grade_ = 0;
::memset(_has_bits_, 0, sizeof(_has_bits_));
mutable_unknown_fields()-&Clear();
176 bool student::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
178 #define DO_(EXPRESSION) if (!(EXPRESSION)) return false
::google::protobuf::uint32
while ((tag = input-&ReadTag()) != 0) {
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// required int32 age = 1;
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive&
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32&(
input, &age_)));
set_has_age();
goto handle_
if (input-&ExpectTag(18)) goto parse_
// required string name = 2;
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
parse_name:
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this-&mutable_name()));
::google::protobuf::internal::WireFormat::VerifyUTF8String(
this-&name().data(), this-&name().length(),
::google::protobuf::internal::WireFormat::PARSE);
goto handle_
if (input-&ExpectTag(24)) goto parse_
// optional int32 grade = 3;
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
parse_grade:
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive&
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32&(
input, &grade_)));
set_has_grade();
goto handle_
if (input-&ExpectAtEnd()) return true;
default: {
handle_uninterpreted:
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
return true;
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, mutable_unknown_fields()));
return true;
243 #undef DO_
246 void student::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// required int32 age = 1;
if (has_age()) {
::google::protobuf::internal::WireFormatLite::WriteInt32(1, this-&age(), output);
// required string name = 2;
if (has_name()) {
::google::protobuf::internal::WireFormat::VerifyUTF8String(
this-&name().data(), this-&name().length(),
::google::protobuf::internal::WireFormat::SERIALIZE);
::google::protobuf::internal::WireFormatLite::WriteString(
2, this-&name(), output);
// optional int32 grade = 3;
if (has_grade()) {
::google::protobuf::internal::WireFormatLite::WriteInt32(3, this-&grade(), output);
if (!unknown_fields().empty()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
unknown_fields(), output);
273 ::google::protobuf::uint8* student::SerializeWithCachedSizesToArray(
::google::protobuf::uint8* target) const {
// required int32 age = 1;
if (has_age()) {
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this-&age(), target);
// required string name = 2;
if (has_name()) {
::google::protobuf::internal::WireFormat::VerifyUTF8String(
this-&name().data(), this-&name().length(),
::google::protobuf::internal::WireFormat::SERIALIZE);
::google::protobuf::internal::WireFormatLite::WriteStringToArray(
2, this-&name(), target);
// optional int32 grade = 3;
if (has_grade()) {
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this-&grade(), target);
if (!unknown_fields().empty()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
unknown_fields(), target);
302 int student::ByteSize() const {
int total_size = 0;
if (_has_bits_[0 / 32] & (0xffu && (0 % 32))) {
// required int32 age = 1;
if (has_age()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int32Size(
this-&age());
// required string name = 2;
if (has_name()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
this-&name());
// optional int32 grade = 3;
if (has_grade()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int32Size(
this-&grade());
if (!unknown_fields().empty()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
unknown_fields());
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = total_
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_
339 void student::MergeFrom(const ::google::protobuf::Message& from) {
GOOGLE_CHECK_NE(&from, this);
const student* source =
::google::protobuf::internal::dynamic_cast_if_available&const student*&(
if (source == NULL) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
MergeFrom(*source);
351 void student::MergeFrom(const student& from) {
GOOGLE_CHECK_NE(&from, this);
if (from._has_bits_[0 / 32] & (0xffu && (0 % 32))) {
if (from.has_age()) {
set_age(from.age());
if (from.has_name()) {
set_name(from.name());
if (from.has_grade()) {
set_grade(from.grade());
mutable_unknown_fields()-&MergeFrom(from.unknown_fields());
367 void student::CopyFrom(const ::google::protobuf::Message& from) {
if (&from == this) return;
MergeFrom(from);
373 void student::CopyFrom(const student& from) {
if (&from == this) return;
MergeFrom(from);
379 bool student::IsInitialized() const {
if ((_has_bits_[0] & 0x) != 0x) return false;
return true;
385 void student::Swap(student* other) {
if (other != this) {
std::swap(age_, other-&age_);
std::swap(name_, other-&name_);
std::swap(grade_, other-&grade_);
std::swap(_has_bits_[0], other-&_has_bits_[0]);
_unknown_fields_.Swap(&other-&_unknown_fields_);
std::swap(_cached_size_, other-&_cached_size_);
396 ::google::protobuf::Metadata student::GetMetadata() const {
protobuf_AssignDescriptorsOnce();
::google::protobuf::M
metadata.descriptor = student_descriptor_;
metadata.reflection = student_reflection_;
405 // @@protoc_insertion_point(namespace_scope)
// namespace caffe
409 // @@protoc_insertion_point(global_scope)
caffe.pb.cc
生成之后,我们编写一个读取文件caffeReader.cpp
#include "caffe.pb.h"
#include&iostream&
#include&ios&
using namespace
void InfoStudents(const caffe::student & stu){
cout&& "student info:"&&
cout&&"name: "&&stu.name()&&
cout&&"age: "&&stu.age()&&
cout&&"grade: "&&stu.grade()&&
int main(void)
stu.set_age(18);
stu.set_name("gongxijun");
stu.set_grade(146);
InfoStudents(stu);
编译完成之后,我们执行如下命令:
g++ caffeRead.cpp -o caffeReader caffe.pb.cc -I /usr/local/protobuf/include -L /usr/local/protobuf/lib -lprotobuf -pthread
生成二进制执行文件caffeReader.我们运行该文件就会显示如下信息:
知道了proto文件是如何使用之,再去caffe.proto中看看caffe中定义的结构体:
message 表示需要传输的的参数的结构体.
caffe.proto中保存的有二进制大文件Blob的结构信息:BlobProto, BlobProtoVector, Datum
BlobProto: 
1 // Specifies the shape (dimensions) of a Blob.
2 //用来表示图片的shape
3 message BlobShape {
repeated int64 dim = 1 [packed = true];
7 message BlobProto {
optional BlobShape shape = 7; //现在用来替换下面的num,channels ,height,width,推荐使用
repeated float data = 5 [packed = true]; //forward计算数据
repeated float diff = 6 [packed = true]; //backward的残差数据
repeated double double_data = 8 [packed = true]; //双精度forward计算数据
repeated double double_diff = 9 [packed = true]; //双精度backward的残差数据
// 4D dimensions -- deprecated.
Use "shape" instead.
optional int32 num = 1 [default = 0]; // 图片个数or 维度
optional int32 channels = 2 [default = 0]; //通过比如rgb便是3维
optional int32 height = 3 [default = 0]; //图片高度
optional int32 width = 4 [default = 0]; //图片宽度
BlobProtoVector:BlobProto的动态数组
message BlobProtoVector {
repeated BlobProto blobs = 1;
Datum是lmdb的数据格式,详情可以看这里 
message Datum {//lmdb中的数据格式
optional int32 channels = 1;//图片通道数比如rgb的通道数为3
optional int32 height = 2;//图片的高度
optional int32 width = 3;//图片的宽度
// the actual image data, in bytes
optional bytes data = 4;//图片的数据.比如rgb的三维数组格式
optional int32 label = 5;//这张图片对应的标签,或者这块图像对应的标签[比如20个分类转换成数字之后对应的[0~19]
// Optionally, the datum could also hold float data.
repeated float float_data = 6;//图片的数据,有时候图片在转换过程中会变成浮点型
// If true data contains an encoded image that need to be decoded
optional bool encoded = 7 [default = false];//是否需要解码
剩下的大部分都是Layer部分和Net部分和Solver部分的参数,关于Blob和Layer,Net还有Solver这四个部分的关系:
&blob作为贯穿整个框架的数据单元,Sovler通过sovler.prototxt【我觉得我可能需要说明一下:.proto和.prototxt的区别吧,这两个都是google protobuff的文件,.proto用来定义结构体参数,.prototxt用来相应的.proto中的结构体的初始化数据】配置初始化Net,然后Net通过调用trainval.prototxt这些参数,来调用对应的Layer,并将数据blob输入到相应的Layer中,Layer来对流入的数据进行计算处理,然后再将计算后的blob数据返回,通过Net流向下一个Layer,每次执行一次,Solver就会计数一次,然后调整learn_rate,descay_weith等权值,参考的是caffe论坛上的这个话题:这里附上链接
阅读(...) 评论()}

我要回帖

更多关于 笔记本电脑什么牌子好 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信