TensorFlow / python> // grammar> It seems to be python's integer division / In Python 2.X, describe from __future__ import division / floor division

Operating environment


Ubuntu 14.04 LTS desktop amd64
GeForce GTX 750 Ti
ASRock Z170M Pro4S [Intel Z170chipset]
TensorFlow v0.11
cuDNN v5.1 for Linux
CUDA v7.5

http://blog.brainpad.co.jp/entry/2016/03/28/170000 Learning.

fully_connected_feed.py The following part I found while reading the code of. The code inside do_eval ().

  # And run one epoch of eval.
  true_count = 0  # Counts the number of correct predictions.
  steps_per_epoch = data_set.num_examples // FLAGS.batch_size

//

I investigated the notation.

It seems that it is an integer division.

http://stackoverflow.com/questions/39968211/what-is-the-meaning-of-in-fully-connected-feed-py

http://stackoverflow.com/questions/183853/in-python-what-is-the-difference-between-and-when-used-for-division

In Python 2.2 or later in the 2.x line, there is no difference for integers unless you perform a from future import division, which causes Python 2.x to adopt the behavior of 3.0

One of the three questions I was worried about in mnist.py was solved.

You should study python more.


More answers were added to [stackoverflow](http://stackoverflow.com/questions/39968211/what-is-the-meaning-of-in-fully-connected-feed-py/39976543#39976543).

As Trejkaz points out in a comment, in Python 3, the // operator means floor division (or integer division): i.e. the result is equivalent to floor(data_set.num_examples / FLAGS.batch_size).

Follow the link from stackoverflow for more details.

Recommended Posts

TensorFlow / python> // grammar> It seems to be python's integer division / In Python 2.X, describe from __future__ import division / floor division
python> link> from __future__ import print_function> Make Python 3.X print () available in Python 2.X
Processing of python3 that seems to be usable in paiza
[Python] It seems that global variables cannot be referenced in Multiprocessing
python> link> from __future__ import absolute_import
[TensorFlow 2] It is recommended to read features from TFRecord in batch units.