4

Hi I encounter these lines in a tensorflow tutorial:

from __future__ import absolute_import, division, print_function, unicode_literals

# Install TensorFlow
try:
  # %tensorflow_version only exists in Colab.
  %tensorflow_version 2.x
except Exception:
  pass

import tensorflow as tf

But I do not understand this line:

%tensorflow_version 2.x

May I know what the modular sign is doing here? Thanks

Kallzvx
  • 594
  • 7
  • 23

1 Answers1

0

It is the magic command for selecting the 2.X TensorFlow version. It's available only in Google Colab.

JaFizz
  • 328
  • 2
  • 20
  • 1
    `%` is not only available in Google Colab. Last I checked, my IPython console wasn't on Google Colab but I have magic methods: https://ipython.readthedocs.io/en/stable/interactive/magics.html – roganjosh Dec 06 '19 at 13:06