简体   繁体   中英

Docstring for batch_norm() does not match latest code in tensorflow.contrib.layers

I am trying to use the latest batch_norm() and found it here: batch_norm . If I use help(tf.contrib.layers.batch_norm) from IPython, I see the following docstring of interest:

Note: When is_training is True the moving_mean and moving_variance need to be updated, by default the update_ops are placed in tf.GraphKeys.UPDATE_OPS so they need to be added as a dependency to the train_op , example:

update_ops = tf.get_collection(tf.GraphKeys.UPDATE_OPS)
if update_ops:
    updates = tf.group(*update_ops)
    total_loss = control_flow_ops.with_dependencies([updates], total_loss)

However the source code at batch_norm has the following docstring which has been corrected.

Note: When is_training is True the moving_mean and moving_variance need to be updated, by default the update_ops are placed in tf.GraphKeys.UPDATE_OPS so they need to be added as a dependency to the train_op , example:

update_ops = tf.get_collection(tf.GraphKeys.UPDATE_OPS)
with tf.control_dependencies(update_ops):
  train_op = optimizer.minimize(loss) 

Using tf.__version__ from IPython prompt, I get '0.12.1'. How can I tell if the code I am running is the same as the latest in tf.contrib.layers? If only the docstring changed and the code is the same, I would rather not upgrade or reinstall tensorflow as I have everything working well with GPU. My install is inside of a mini conda environment and tensorflow was originally installed with pip from inside this environment. Also, if I do need a different version, what is the best way to get it and then test that I have the matching version from tf.contrib.layers?

I was able to verify that I did not have the latest code by doing a diff on the file of interest with my local copy. I did this by first downloading the file layers.py from Github at layers.py . I clicked on the raw button and then saved the image to a local directory. In my case the local copy was located in my miniconda directory under site-packages . At that point it was apparent that my version of tensorflow needed to be updated so I installed the latest version. This install broke an existing miniconda environment however which was unexpected. See installing tensorflow...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM