本文整理汇总了C++中LayerPtr::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ LayerPtr::getName方法的具体用法?C++ LayerPtr::getName怎么用?C++ LayerPtr::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LayerPtr
的用法示例。
在下文中一共展示了LayerPtr::getName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: console_filter_selection
int console_filter_selection(ContextPtr env, char *cmd) {
if(!cmd) return 0;
LinkList<Filter> &list = env->getFilters();
LinkList<Filter>::iterator it = std::find_if(list.begin(), list.end(), [&](FilterPtr filter) {
return filter->getName() == cmd;
});
if(it == list.end()) {
::error("filter not found: %s", cmd);
return 0;
}
FilterPtr filt = *it;
ViewPortPtr screen = getSelectedScreen();
if(!screen) {
::error("no screen currently selected");
return 0;
}
LayerPtr lay = getSelectedLayer();
if(!lay) {
::error("no layer selected for effect %s", filt->getName().c_str());
return 0;
}
if(!filt->new_instance()->apply(lay)) {
::error("error applying filter %s on layer %s", filt->getName().c_str(), lay->getName().c_str());
return 0;
}
// select automatically the new filter
// lay->filters.sel(0);
// ff->sel(true);
return 1;
}
示例2: createCTCLayer
LayerPtr createCTCLayer(string name,
size_t numClasses,
bool useGpu,
bool normByTimes,
LayerPtr dataLayer,
LayerPtr labelLayer) {
LayerMap layerMap;
layerMap[dataLayer->getName()] = dataLayer;
layerMap[labelLayer->getName()] = labelLayer;
ParameterMap parameterMap;
LayerConfig layerConfig;
layerConfig.set_name(name);
layerConfig.set_type("ctc");
layerConfig.set_size(numClasses);
layerConfig.set_norm_by_times(normByTimes);
layerConfig.add_inputs();
LayerInputConfig& input0 = *(layerConfig.mutable_inputs(0));
input0.set_input_layer_name(dataLayer->getName());
layerConfig.add_inputs();
LayerInputConfig& input1 = *(layerConfig.mutable_inputs(1));
input1.set_input_layer_name(labelLayer->getName());
LayerPtr layer = LayerPtr(new CTCLayer(layerConfig));
layerMap[layer->getName()] = layer;
layer->init(layerMap, parameterMap);
ActivationFunction* softmaxActivation = ActivationFunction::create("softmax");
softmaxActivation->forward(dataLayer->getOutput()).check();
layer->forward(PASS_GC);
layer->backward();
softmaxActivation->backward(dataLayer->getOutput()).check();
return layer;
}
示例3: console_blit_param_selection
int console_blit_param_selection(ContextPtr env, char *cmd) {
if(!cmd) return 0;
ViewPortPtr screen = getSelectedScreen();
if(!screen) {
::error("no screen currently selected");
return 0;
}
LayerPtr lay = getSelectedLayer();
if(!lay) {
::error("no layer currently selected");
return 0;
}
BlitInstancePtr b = lay->getCurrentBlit();
if(!b) {
::error("no blit selected on layer %s", lay->getName().c_str());
return 0;
}
// find the values after the first blank space
char *p;
for(p = cmd; *p != '\0'; p++)
if(*p == '=') {
*p = '\0';
if(*(p - 1) == ' ')
*(p - 1) = '\0';
p++;
break;
}
while(*p == ' ') p++; // jump all spaces
if(*p == '\0') return 0; // no value was given
LinkList<ParameterInstance> &list = b->getParameters();
LinkList<ParameterInstance>::iterator it = std::find_if(list.begin(), list.end(), [&](ParameterInstancePtr p) {
return p->getName() == cmd;
});
if(it == list.end()) {
error("parameter %s not found in blit %s", cmd, b->getName().c_str());
return 0;
}
ParameterInstancePtr param = *it;
func("parameter %s found in blit %s", param->getName().c_str(), b->getName().c_str());
param->parse(p);
return 1;
}
示例4: createWarpCTCLayer
LayerPtr createWarpCTCLayer(string name,
size_t numClasses,
bool useGpu,
bool normByTimes,
LayerPtr dataLayer,
LayerPtr labelLayer) {
LayerMap layerMap;
layerMap[dataLayer->getName()] = dataLayer;
layerMap[labelLayer->getName()] = labelLayer;
ParameterMap parameterMap;
LayerConfig layerConfig;
layerConfig.set_name(name);
layerConfig.set_type("warp_ctc");
layerConfig.set_size(numClasses);
layerConfig.set_blank(numClasses - 1);
layerConfig.set_norm_by_times(normByTimes);
layerConfig.add_inputs();
LayerInputConfig& input0 = *(layerConfig.mutable_inputs(0));
input0.set_input_layer_name(dataLayer->getName());
layerConfig.add_inputs();
LayerInputConfig& input1 = *(layerConfig.mutable_inputs(1));
input1.set_input_layer_name(labelLayer->getName());
LayerPtr layer = LayerPtr(new WarpCTCLayer(layerConfig));
layerMap[layer->getName()] = layer;
layer->init(layerMap, parameterMap);
layer->forward(PASS_GC);
layer->backward();
return layer;
}
示例5: console_param_selection
int console_param_selection(ContextPtr env, char *cmd) {
if(!cmd) return 0;
if(!strlen(cmd)) return 0;
ViewPortPtr screen = getSelectedScreen();
if(!screen) {
::error("no screen currently selected");
return 0;
}
LayerPtr lay = getSelectedLayer();
if(!lay) {
::error("no layer currently selected");
return 0;
}
FilterInstancePtr filt = getSelectedFilter();
// find the values after the first blank space
char *p;
for(p = cmd; *p != '\0'; p++)
if(*p == '=') {
*p = '\0';
if(*(p - 1) == ' ')
*(p - 1) = '\0';
p++;
break;
}
while(*p == ' ') p++; // jump all spaces
if(*p == '\0') return 0; // no value was given
if(filt) { ///////////////////////// parameters for filter
LinkList<ParameterInstance> &list = filt->getParameters();
LinkList<ParameterInstance>::iterator it = std::find_if(list.begin(), list.end(), [&] (ParameterInstancePtr ¶m) {
return param->getName() == cmd;
});
if(it == list.end()) {
error("parameter %s not found in filter %s", cmd, filt->getName().c_str());
return 0;
} else {
ParameterInstancePtr param = *it;
func("parameter %s found in filter %s",
param->getName().c_str(), filt->getName().c_str());
// parse from the string to the value
param->parse(p);
}
} else { /////// parameters for layer
LinkList<ParameterInstance> &list = lay->getParameters();
LinkList<ParameterInstance>::iterator it = std::find_if(list.begin(), list.end(), [&] (ParameterInstancePtr ¶m) {
return param->getName() == cmd;
});
if(it == list.end()) {
error("parameter %s not found in layers %s", cmd, lay->getName().c_str());
return 0;
} else {
ParameterInstancePtr param = *it;
func("parameter %s found in layer %s at position %u",
param->getName().c_str(), lay->getName().c_str());
// parse from the string to the value
param->parse(p);
}
}
return 1;
}
示例6: console_blit_param_completion
int console_blit_param_completion(ContextPtr env, char *cmd) {
ViewPortPtr screen = getSelectedScreen();
if(!screen) {
::error("no screen currently selected");
return 0;
}
LayerPtr lay = getSelectedLayer();
if(!lay) {
::error("no layer currently selected");
return 0;
}
BlitInstancePtr b = lay->getCurrentBlit();
if(!b) {
::error("no blit selected on layer %s", lay->getName().c_str());
return 0;
}
// Find completions
// Find completions
ParameterInstancePtr exactParam;
LinkList<ParameterInstance> retList;
LinkList<ParameterInstance> &list = b->getParameters();
std::string cmdString(cmd);
std::transform(cmdString.begin(), cmdString.end(), cmdString.begin(), ::tolower);
std::copy_if(list.begin(), list.end(), retList.begin(), [&] (ParameterInstancePtr param) {
std::string name = param->getName();
std::transform(name.begin(), name.end(), name.begin(), ::tolower);
if(name == cmdString) {
exactParam = param;
}
return name.compare(cmdString) == 0;
});
if(retList.empty()) return 0;
if(exactParam != NULL) {
snprintf(cmd, MAX_CMDLINE, "%s = ", exactParam->getName().c_str());
return 1;
}
if(cmdString.empty()) {
notice("List available blit parameters");
} else {
notice("List available blit parameters starting with \"%s\"", cmd);
}
int c = 0;
std::for_each(retList.begin(), retList.end(), [&] (ParameterInstancePtr p) {
switch(p->getType()) {
case Parameter::BOOL:
::act("(bool) %s = %s :: %s", p->getName().c_str(),
(*(bool*)p->get() == true) ? "true" : "false",
p->getDescription().c_str());
break;
case Parameter::NUMBER:
::act("(number) %s = %.2f :: %s", p->getName().c_str(),
*(float*)p->get(),
p->getDescription().c_str());
break;
case Parameter::STRING:
::act("(string) %s = %s :: %s", p->getName().c_str(), (char*)p->get(), p->getDescription().c_str());
break;
case Parameter::POSITION: {
float *val = (float*)p->get();
::act("(position) %s = %.2f x %.2f :: %s", p->getName().c_str(),
val[0], val[1],
p->getDescription().c_str());
}
break;
case Parameter::COLOR:
::act("%s (color) %s", p->getName().c_str(), p->getDescription().c_str());
break;
default:
::error("%s (unknown) %s", p->getName().c_str(), p->getDescription().c_str());
break;
}
++c;
});
return c;
}