本文整理汇总了C++中Net::name方法的典型用法代码示例。如果您正苦于以下问题:C++ Net::name方法的具体用法?C++ Net::name怎么用?C++ Net::name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Net
的用法示例。
在下文中一共展示了Net::name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[]) {
// Main thread for the server
// Spawn a new thread for each request
po::variables_map vm = parse_opts(argc, argv);
debug = vm["debug"].as<bool>();
gpu = vm["gpu"].as<bool>();
Caffe::set_phase(Caffe::TEST);
if (vm["gpu"].as<bool>())
Caffe::set_mode(Caffe::GPU);
else
Caffe::set_mode(Caffe::CPU);
// load all models at init
ifstream file(vm["nets"].as<string>().c_str());
string net_name;
while (file >> net_name) {
string net = vm["common"].as<string>() + "configs/" + net_name;
Net<float>* temp = new Net<float>(net);
const std::string name = temp->name();
nets[name] = temp;
std::string weights = vm["common"].as<string>() +
vm["weights"].as<string>() + name + ".caffemodel";
nets[name]->CopyTrainedLayersFrom(weights);
}
// how many threads to spawn before exiting
// -1 to stay indefinitely open
int total_thread_cnt = vm["threadcnt"].as<int>();
int socketfd = SERVER_init(vm["portno"].as<int>());
// Listen on socket
listen(socketfd, 10);
LOG(INFO) << "Server is listening for requests on " << vm["portno"].as<int>();
// Main Loop
int thread_cnt = 0;
while (1) {
pthread_t new_thread_id;
int client_sock = accept(socketfd, (sockaddr*)0, (unsigned int*)0);
if (client_sock == -1) {
LOG(ERROR) << "Failed to accept.\n";
continue;
} else
new_thread_id = request_thread_init(client_sock);
++thread_cnt;
if (thread_cnt == total_thread_cnt) {
if (pthread_join(new_thread_id, NULL) != 0) {
LOG(FATAL) << "Failed to join.\n";
}
break;
}
}
return 0;
}
示例2:
EXPORT const char *caffe_net_name(void *netAnon)
{
Net<float> *net = (Net<float> *)netAnon;
return net->name().c_str();
}