Nono.MA

Use TensorFlow 2.x in Google Colab

LAST UPDATED NOVEMBER 3, 2021

try:
    %tensorflow_version 2.x
except Exception:
  pass

import tensorflow as tf

Note: that %tensorflow_version is only available in Colab and not in regular Python.

Note: This was useful when TensorFlow 1 was the default. But now TensorFlow 2 is available in Colab by default.

CodeTensorflow