You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by gi...@git.apache.org on 2017/09/02 20:26:26 UTC
[GitHub] piiswrong commented on a change in pull request #7626: modify gluon image_classification for imagenet
piiswrong commented on a change in pull request #7626: modify gluon image_classification for imagenet
URL: https://github.com/apache/incubator-mxnet/pull/7626#discussion_r136703258
##########
File path: src/io/iter_normalize.h
##########
@@ -144,35 +148,71 @@ class ImageNormalizeIter : public IIterator<DataInst> {
float illumination =
rand_uniform(rnd_) * param_.max_random_illumination * 2 - param_.max_random_illumination;
- if (param_.mean_r > 0.0f || param_.mean_g > 0.0f ||
- param_.mean_b > 0.0f || param_.mean_a > 0.0f) {
- // subtract mean per channel
- data[0] -= param_.mean_r;
- if (data.shape_[0] >= 3) {
- data[1] -= param_.mean_g;
- data[2] -= param_.mean_b;
- }
- if (data.shape_[0] == 4) {
- data[3] -= param_.mean_a;
+ // setup mean if not loaded from file, should happen only once
+ if (!meanfile_ready_ || (meanimg_.shape_ != data.shape_)) {
+ if (param_.mean_r > 0.0f || param_.mean_g > 0.0f ||
+ param_.mean_b > 0.0f || param_.mean_a > 0.0f) {
+ // setup meanimg using mean_r/g/b/a
+ meanimg_.Resize(data.shape_);
+ switch (static_cast<int>(data.shape_[0])) {
+ case 4: {
+ meanimg_[3] = param_.mean_a;
Review comment:
But reshaping and re filling meanimg on each iter is slow
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services