(aspect_ratios_.size()+1) is a typo ? I think right equation is : num_priors_ += aspect_ratios_.size() * (pow(densitys_[i],2)-1)