void Blob<Dtype>::FromProto(const BlobProto& proto) { LOG(INFO)<<"FromProto size = "<<proto.num() <<" "<<proto.channels() << " "<<proto.height()<<" "<< proto.width()<<" "<< proto.depth(); if(proto.depth() ==0) { LOG(INFO)<< "proto depth is 0, converting to 1 for 2D models to 3D models..."; Reshape(proto.num(), proto.channels(), proto.height(), proto.width(), 1); }else{ Reshape(proto.num(), proto.channels(), proto.height(), proto.width(), proto.depth()); } // copy data Dtype* data_vec = mutable_cpu_data(); /* for testing only Dtype data_vec_sum=0; for (int i = 0; i < count_; ++i) { data_vec_sum=data_vec_sum+data_vec[i]; } LOG(INFO)<<"bolb sum value = "<<data_vec_sum; */ for (size_t i = 0; i < count_; ++i) { data_vec[i] = proto.data(i); //LOG(INFO)<<"proto.data(i) ="<<proto.data(i); } //LOG(INFO)<<"proto.data[11870779] ="<<proto.data(11870779); //sleep(20); // LOG(INFO)<<"proto.diff_size= "<<proto.diff_size(); if (proto.diff_size() > 0) { Dtype* diff_vec = mutable_cpu_diff(); for (size_t i = 0; i < count_; ++i) { diff_vec[i] = proto.diff(i); } } //if (Caffe::mode()==Caffe::GPU) { // gpu_data(); // } }
void Blob<Dtype>::FromProtoWithExtraCopy(const BlobProto& proto){ // reshape other dimention but remain the same number of channels; Reshape(proto.num(), this->channels(), proto.height(), proto.width(), proto.depth()); // copy data Dtype* data_vec = mutable_cpu_data(); int sourceDataSize =proto.data_size(); for (int i = 0; i < count_; ++i) { data_vec[i] = proto.data(i%sourceDataSize); } if (proto.diff_size() > 0) { Dtype* diff_vec = mutable_cpu_diff(); for (int i = 0; i < count_; ++i) { diff_vec[i] = proto.diff(i%sourceDataSize); } } }
void Blob<Dtype>::FromProtoFC2Conv(const BlobProto& proto){ // Note that we do not change the shape of taget layer blob (convolution) // reshape other dimention but remain the same number of channels; //Reshape(proto.num(), this->channels(), proto.height(), proto.width(), proto.depth()); // copy data Dtype* data_vec = mutable_cpu_data(); size_t proto_count =proto.num()*proto.channels()*proto.height()*proto.width()*proto.depth(); CHECK_EQ(proto_count,count_); for (size_t i = 0; i < count_; ++i) { data_vec[i] = proto.data(i); } // LOG(INFO)<<"proto.diff_size= "<<proto.diff_size(); if (proto.diff_size() > 0) { Dtype* diff_vec = mutable_cpu_diff(); for (size_t i = 0; i < count_; ++i) { diff_vec[i] = proto.diff(i); } } }