当前位置: 首页>>代码示例>>C++>>正文


C++ SolverParameter类代码示例

本文整理汇总了C++中SolverParameter的典型用法代码示例。如果您正苦于以下问题:C++ SolverParameter类的具体用法?C++ SolverParameter怎么用?C++ SolverParameter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SolverParameter类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: InitSolverFromProtoString

 virtual void InitSolverFromProtoString(const string& proto) {
   SolverParameter param;
   CHECK(google::protobuf::TextFormat::ParseFromString(proto, &param));
   // Set the solver_mode according to current Caffe::mode.
   switch (Caffe::mode()) {
     case Caffe::CPU:
       param.set_solver_mode(SolverParameter_SolverMode_CPU);
       break;
     case Caffe::GPU:
       param.set_solver_mode(SolverParameter_SolverMode_GPU);
       break;
     default:
       LOG(FATAL) << "Unknown Caffe mode: " << Caffe::mode();
   }
   solver_.reset(new SGDSolver<Dtype>(param));
 }
开发者ID:allenlithu,项目名称:caffe_prl,代码行数:16,代码来源:test_solver.cpp

示例2: blob_shape_by_name

SolverParameter ModelServer<Dtype>::prepare_model() {
  NetParameter net;
  solver->net()->ToProto(&net);

  for (int i = 0; i < net.layer_size(); ++i) {
    LayerParameter& layer = *net.mutable_layer(i);
    layer.clear_blobs();
    if ((layer.type().find("Data") != std::string::npos)
        && (layer.has_remote_data_param())) {
      layer.set_type("RemoteData");

      for (int j = 0; j < layer.top_size(); ++j) {
        *layer.mutable_remote_data_param()->add_shape()
          = blob_shape_by_name(layer.top(j));
      }
    }
  }

  SolverParameter ret = solver->param();
  ret.clear_net();
  ret.clear_net_param();
  ret.clear_test_net();
  ret.clear_test_net_param();
  ret.clear_train_net();
  *ret.mutable_train_net_param() = net;

  return ret;
}
开发者ID:0hm,项目名称:caffe,代码行数:28,代码来源:ModelServer.cpp

示例3: LOG

P2PSync<Dtype>::P2PSync(shared_ptr<Solver<Dtype> > root_solver,
                        P2PSync<Dtype>* parent, const SolverParameter& param)
    : GPUParams<Dtype>(root_solver, param.device_id()),
      parent_(parent),
      children_(),
      queue_(),
      initial_iter_(root_solver->iter()),
      solver_() {
#ifndef CPU_ONLY
    int initial_device;
    CUDA_CHECK(cudaGetDevice(&initial_device));
    const int self = param.device_id();
    CUDA_CHECK(cudaSetDevice(self));

    if (parent == NULL) {
        solver_ = root_solver;
    } else {
        Caffe::set_root_solver(false);
        solver_.reset(new WorkerSolver<Dtype>(param, root_solver.get()));
        Caffe::set_root_solver(true);
    }
    this->configure(solver_.get());
    solver_->add_callback(this);

    if (parent) {
        // Enable p2p access between devices
        const int peer = parent->solver_->param().device_id();
        int access;
        CUDA_CHECK(cudaDeviceCanAccessPeer(&access, self, peer));
        if (access) {
            CUDA_CHECK(cudaDeviceEnablePeerAccess(peer, 0));
        } else {
            LOG(INFO)<< "GPU " << self << " does not have p2p access to GPU " << peer;
        }
        // Allocate receiving buffer on parent
        CUDA_CHECK(cudaSetDevice(peer));
        CUDA_CHECK(cudaMalloc(&parent_grads_, size_ * sizeof(Dtype)));
        CUDA_CHECK(cudaSetDevice(self));
    }

    CUDA_CHECK(cudaSetDevice(initial_device));
#else
    NO_GPU;
#endif
}
开发者ID:flair2005,项目名称:Caffe-Solution,代码行数:45,代码来源:parallel.cpp

示例4:

int
SolverHooks::setOption(const char *optionname, Value val, Simulation *S){
	/* FIXME need to check if the system is built? */
	/* FIXME check if we have got a solver assigned? */
	SolverParameters pp = S->getParameters();

	try{
		SolverParameter p = pp.getParameter(optionname);
		try{
			p.setValueValue(val);
		}catch(std::runtime_error E){
			return SLVREQ_WRONG_OPTION_VALUE_TYPE;
		}
	}catch(std::runtime_error E){
		return SLVREQ_INVALID_OPTION_NAME;
	}
	return 0;
}
开发者ID:sauravkumar2014,项目名称:ASCEND,代码行数:18,代码来源:solverhooks.cpp

示例5: InitSolverFromProtoString

 virtual void InitSolverFromProtoString(const string& proto) {
   SolverParameter param;
   CHECK(google::protobuf::TextFormat::ParseFromString(proto, &param));
   // Disable saving a final snapshot so the tests don't pollute the user's
   // working directory with useless snapshots.
   param.set_snapshot_after_train(false);
   // Set the solver_mode according to current Caffe::mode.
   switch (Caffe::mode()) {
     case Caffe::CPU:
       param.set_solver_mode(SolverParameter_SolverMode_CPU);
       break;
     case Caffe::GPU:
       param.set_solver_mode(SolverParameter_SolverMode_GPU);
       break;
     default:
       LOG(FATAL) << "Unknown Caffe mode: " << Caffe::mode();
   }
   solver_.reset(new MockSGDSolver(param));
 }
开发者ID:FangZhenpeng,项目名称:caffe,代码行数:19,代码来源:test_sgd_solver.cpp

示例6: InitSolverFromProtoString

 virtual void InitSolverFromProtoString(const string& proto) {
   SolverParameter param;
   CHECK(google::protobuf::TextFormat::ParseFromString(proto, &param));
   // Set the solver_mode according to current Caffe::mode.
   switch (Caffe::mode()) {
     case Caffe::CPU:
       param.set_solver_mode(SolverParameter_SolverMode_CPU);
       break;
     case Caffe::GPU:
       param.set_solver_mode(SolverParameter_SolverMode_GPU);
       break;
     default:
       LOG(FATAL) << "Unknown Caffe mode: " << Caffe::mode();
   }
   InitSolver(param);
   delta_ = (solver_type() == SolverParameter_SolverType_ADAGRAD ||
       solver_type() == SolverParameter_SolverType_RMSPROP) ?
       param.delta() : 0;
 }
开发者ID:kimimj,项目名称:caffe,代码行数:19,代码来源:test_gradient_based_solver.cpp

示例7: LOG

void Solver<Dtype>::Init(const SolverParameter& param) {
  LOG(INFO) << "Initializing solver from parameters: " << std::endl
            << param.DebugString();
  param_ = param;
  if (param_.random_seed() >= 0) {
    Caffe::set_random_seed(param_.random_seed());
  }
  // Scaffolding code
  InitTrainNet();
  InitTestNets();
  LOG(INFO) << "Solver scaffolding done.";
}
开发者ID:VikingMew,项目名称:dec,代码行数:12,代码来源:solver.cpp

示例8: LOG

void Solver<Dtype>::Init(const SolverParameter& param) {
  LOG(INFO) << "Initializing solver from parameters: " << std::endl
            << param.DebugString();
  param_ = param;
  CHECK_GE(param_.average_loss(), 1) << "average_loss should be non-negative.";
  if (param_.random_seed() >= 0) {
    Caffe::set_random_seed(param_.random_seed());
  }
  // Scaffolding code
  InitTrainNet();
  InitTestNets();
  LOG(INFO) << "Solver scaffolding done.";
  iter_ = 0;
  current_step_ = 0;
}
开发者ID:madiken,项目名称:skaffe_private_old,代码行数:15,代码来源:solver.cpp

示例9: CHECK

void Solver<Dtype>::Init(const SolverParameter& param) {
  CHECK(Caffe::root_solver() || root_solver_)
      << "root_solver_ needs to be set for all non-root solvers";
  LOG_IF(INFO, Caffe::root_solver()) << "Initializing solver from parameters: "
    << std::endl << param.DebugString();
  param_ = param;
  CHECK_GE(param_.average_loss(), 1) << "average_loss should be non-negative.";
  CheckSnapshotWritePermissions();
  if (Caffe::root_solver() && param_.random_seed() >= 0) {
    Caffe::set_random_seed(param_.random_seed());
  }
  // Scaffolding code
  InitTrainNet();
  if (Caffe::root_solver()) {
    InitTestNets();
    LOG(INFO) << "Solver scaffolding done.";
  }
  iter_ = 0;
  current_step_ = 0;
}
开发者ID:kovibalu,项目名称:caffe-cnntools,代码行数:20,代码来源:solver.cpp

示例10: runtime_error

const string
SolverParameters::toString() const{
	stringstream ss;
	ss << "SOLVERPARAMETERS:TOSTRING:" << endl;
	ss << "Number of parameters: " << p.num_parms << endl;

	iterator i;
	for(i = begin(); i<end(); ++i){
		SolverParameter p = *i;
#if 0
		ss << p.getLabel() << " [" << p.getDescription() << "]: ";
#else
		ss << p.getName() << ": ";
#endif
		if(p.isInt()){
			ss << p.getIntValue();
		}else if(p.isReal()){
			ss << p.getRealValue();
		}else if(p.isBool()){
			ss << (p.getBoolValue() ? "true" : "false");
		}else if(p.isStr()){
			ss << p.getStrValue();
		}else{
			throw runtime_error("Unhandled case");
		}
		ss << endl;
	}
	return ss.str();
}
开发者ID:sauravkumar2014,项目名称:ASCEND,代码行数:29,代码来源:solverparameters.cpp


注:本文中的SolverParameter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。