tensorflow / tensorflow/models
The batchnorm problem about resnet_v2
@marksandler2 is already working on this.
Since Jun 19, 2020.
- Dominant language
- Python
- Stars
- 77.7k
- Forks
- 44.8k
- PR merge metrics
- No merged PRs in 30d
Description
The problem
I tried to run ResNet by using the slim version in /models/research/slim/nets/resnetv2.py, but the moving_mean and the moving_variance didn't be saved, even if I did as the official notes:
opt = tf.train.AdamOptimizer(learning_rate=rate)
update_ops = tf.get_collection(tf.GraphKeys.UPDATE_OPS)
with tf.control_dependencies(update_ops):
train_op = opt.minimize(loss, global_step=global_step)
tf.summary.scalar('loss', loss)
tf.summary.scalar('accuracy', eval_correct)
for v in tf.global_variables():
if ('moving_mean' in v.name) or ('moving_variance' in v.name):
print(v)
tf.summary.histogram(v.name, v)
This phenomenon contributed to a fact that the train accuracy increased rapidly while the test accuracy increased slowly. It seemed like over-fitting, but obviously it was not, because the result was normal when I run resnet by using version v1. This is the log:
epoch 0 train set acc:0.0
epoch 0 test accuracy:0.007706925675675676
epoch 1 train set acc:0.39310128348214285
epoch 1 test accuracy:0.2808695972758473
epoch 2 train set acc:0.7352120535714286
epoch 2 test accuracy:0.3768355408980409
epoch 3 train set acc:0.77880859375
epoch 3 test accuracy:0.42969364453739456
epoch 4 train set acc:0.8028041294642857
epoch 4 test accuracy:0.4497834888459889
epoch 5 train set acc:0.8160923549107143
epoch 5 test accuracy:0.45564090876590874
epoch 6 train set acc:0.8241838727678571
epoch 6 test accuracy:0.46629050925925924
epoch 7 train set acc:0.8352399553571429
epoch 7 test accuracy:0.4792214089089089
epoch 8 train set acc:0.844482421875
epoch 8 test accuracy:0.4857497005934506
epoch 9 train set acc:0.8494698660714286
epoch 9 test accuracy:0.47268250393250394
epoch 10 train set acc:0.8593052455357143
epoch 10 test accuracy:0.49918836246961246
epoch 11 train set acc:0.8661411830357143
epoch 11 test accuracy:0.49487322143572143
Environment
The batchnorm function which I used was slim.batchnorm, and my python version was 3.6.3, and tensorflow version was 1.7.0
I nearly read all of the methods on the websites, still I couldn't solve it. I'm very appreciated that if you can deal with this problem.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.