Browse Source

fix lrn within channel

tags/20171017
nihui 8 years ago
parent
commit
3e8a5ba264
2 changed files with 12 additions and 6 deletions
  1. +4
    -2
      src/layer/arm/lrn_arm.cpp
  2. +8
    -4
      src/layer/lrn.cpp

+ 4
- 2
src/layer/arm/lrn_arm.cpp View File

@@ -70,8 +70,6 @@ int LRN_arm::forward_inplace(Mat& bottom_top_blob) const
}
}

float alpha_div_size = alpha / local_size;

if (region_type == NormRegion_ACROSS_CHANNELS)
{
Mat square_sum;
@@ -80,6 +78,8 @@ int LRN_arm::forward_inplace(Mat& bottom_top_blob) const
return -100;
square_sum.fill(0.f);

const float alpha_div_size = alpha / local_size;

#pragma omp parallel for
for (int q=0; q<channels; q++)
{
@@ -175,6 +175,8 @@ int LRN_arm::forward_inplace(Mat& bottom_top_blob) const

const int maxk = local_size * local_size;

const float alpha_div_size = alpha / maxk;

// norm window offsets
std::vector<int> _space_ofs(maxk);
int* space_ofs = &_space_ofs[0];


+ 8
- 4
src/layer/lrn.cpp View File

@@ -100,12 +100,12 @@ int LRN::forward(const Mat& bottom_blob, Mat& top_blob) const
}
}

float alpha_div_size = alpha / local_size;

if (region_type == NormRegion_ACROSS_CHANNELS)
{
top_blob.fill(0.f);

const float alpha_div_size = alpha / local_size;

#pragma omp parallel for
for (int q=0; q<channels; q++)
{
@@ -149,6 +149,8 @@ int LRN::forward(const Mat& bottom_blob, Mat& top_blob) const

const int maxk = local_size * local_size;

const float alpha_div_size = alpha / maxk;

// norm window offsets
std::vector<int> _space_ofs(maxk);
int* space_ofs = &_space_ofs[0];
@@ -225,8 +227,6 @@ int LRN::forward_inplace(Mat& bottom_top_blob) const
}
}

float alpha_div_size = alpha / local_size;

if (region_type == NormRegion_ACROSS_CHANNELS)
{
Mat square_sum;
@@ -235,6 +235,8 @@ int LRN::forward_inplace(Mat& bottom_top_blob) const
return -100;
square_sum.fill(0.f);

const float alpha_div_size = alpha / local_size;

#pragma omp parallel for
for (int q=0; q<channels; q++)
{
@@ -278,6 +280,8 @@ int LRN::forward_inplace(Mat& bottom_top_blob) const

const int maxk = local_size * local_size;

const float alpha_div_size = alpha / maxk;

// norm window offsets
std::vector<int> _space_ofs(maxk);
int* space_ofs = &_space_ofs[0];


Loading…
Cancel
Save