本文整理汇总了C++中Tree::GetChildren方法的典型用法代码示例。如果您正苦于以下问题:C++ Tree::GetChildren方法的具体用法?C++ Tree::GetChildren怎么用?C++ Tree::GetChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tree
的用法示例。
在下文中一共展示了Tree::GetChildren方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void SuperCategoryLayer<Dtype>::Forward_cpu(const vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top) {
//For Data
for(int n = 0; n < N_; ++n) {
for(int i = depth_-2; i >= 0; --i)
{
int node_cnt;
if( i == depth_-2)
node_cnt = node_num_per_level_[i];
else
node_cnt = node_num_per_level_[i+1];
Blob<Dtype> * bottoms;
if( i == depth_-2 )
bottoms = bottom[0];
else
bottoms = top[i+1];
Dtype * top_data = &top[i]->mutable_cpu_data()[node_num_per_level_[i]*n];
int * mark_data = &mark_[i]->mutable_cpu_data()[node_num_per_level_[i]*n];
const Dtype * bottom_data = &bottoms->cpu_data()[node_cnt*n]; //is equal.
int base_idx = base_index_per_level_[i];
for(int j = 0; j < node_num_per_level_[i]; ++j ) {
Tree * node = serialized_tree_[base_idx + j];
const std::vector<shared_ptr<Tree> > * children = node->GetChildren();
if( children->size() == 0 )
{
CHECK_EQ(i, depth_-2);
//caffe_mul<Dtype>(N_,&blob_data[N_*j], &bottom_data[N_*j], &top_data[N_*j]);
top_data[j] = bottom_data[j];
}
else{
int node_label = node->GetLabel();
top_data[node_label] = -1 * std::numeric_limits<Dtype>::max();
for(auto it = children->cbegin(); it != children->cend(); ++it) {
int label = (*it)->GetLabel();
//caffe_mul<Dtype>(N_,&blob_data[idx*N_],&bottom_data[idx*N_],temp_.mutable_cpu_data());
//caffe_add<Dtype>(N_,temp_.cpu_data(),&top_data[j*N_],&top_data[j*N_]);
if( top_data[node_label] < bottom_data[label] )
{
top_data[node_label] = bottom_data[label];
mark_data[node_label] = label;
}
}
}
}
}
}
}
示例2: Dtype
void SuperCategoryLayer<Dtype>::Backward_cpu(const vector<Blob<Dtype>*>& top,
const vector<bool>& propagate_down,
const vector<Blob<Dtype>*>& bottom) {
caffe_set(bottom[0]->count(), Dtype(0), bottom[0]->mutable_cpu_diff());
if( propagate_down[0] ) {
for(int n = 0; n < N_; ++n) {
for(int i = 0; i < depth_-1; ++i) {
int node_cnt;
if( i == depth_-2)
node_cnt = node_num_per_level_[i];
else
node_cnt = node_num_per_level_[i+1];
const Dtype * top_diff = &top[i]->cpu_diff()[n*node_num_per_level_[i]];
const int * mark_data = &mark_[i]->cpu_data()[n*node_num_per_level_[i]];
Dtype * bottom_diff;
if( i + 1 == depth_-1 ){
bottom_diff = &bottom[0]->mutable_cpu_diff()[n*node_cnt];
}
else {
bottom_diff = &top[i+1]->mutable_cpu_diff()[n*node_cnt];
}
int base_idx = base_index_per_level_[i];
for(int j = 0; j < node_num_per_level_[i]; ++j) {
Tree * node = serialized_tree_[base_idx + j];
const std::vector<shared_ptr<Tree> > * children = node->GetChildren();
if( children->size() == 0 ) { //this layer is connected with bottom layer
//caffe_mul<Dtype>(N_,&top_diff[j*N_],&bottom_data[j*N_],&blob_diff[j*N_]);
//caffe_mul<Dtype>(N_,&top_diff[j*N_],&blob_data[j*N_],&bottom_diff[j*N_]);
CHECK_EQ(i, depth_-2);
bottom_diff[j] = top_diff[j];
}
else {
int node_label = node->GetLabel();
int label = mark_data[node_label];
bottom_diff[label] += top_diff[node_label];
}
}
}
}
}
}
示例3: sgftree_test
// test for sgftree function
// [[Rcpp::export]]
void sgftree_test(std::string sgf)
{
std::vector<unsigned int> c;
Tree<std::string> t = MakeSgfBranchTree(sgf);
Rcpp::Rcout << "get_sgftree() has finished!\n";
Rcpp::Rcout << "SGF = " << sgf << "\n";
for (unsigned int i = 0; i < t.size(); i++)
{
Rcpp::Rcout << i << " : " << t.Get(i) <<
"\n parent = " << t.GetParent(i) << "\n children = ";
c = t.GetChildren(i);
for (unsigned int j = 0; j < c.size(); j++)
Rcpp::Rcout << c[j] << " ";
Rcpp::Rcout << "\n";
}
MakeSgfNodeTree(sgf);
}