This simple tutorial show you how to set Tensorflow 2 version in google Colab. It is simple step by step, picture by picture guide.

I try to find a way to set Tensorflow 2 version on Colab. Are you using Colab? I love it.

### Set a version of Tensorflow

To set the Tensorflow version in colab.research.google.com- execute following code %tensorflow_version
- go to top menu - Runtime - Restart and Run all

In [0]:

```
from __future__ import absolute_import, division, print_function, unicode_literals
try:
# %tensorflow_version only exists in Colab.
%tensorflow_version 2.x
except Exception:
pass
import tensorflow as tf
import matplotlib.pyplot as plt
import numpy as np
print(tf.__version__)
# This looks like a vector right ?
tensor_OneDimension = np.array([1,2,3,4,5])
# The acess tensor elenents by index
first_element = tensor_OneDimension[0]
last_element = tensor_OneDimension[4]
print("first element :",first_element)
print("second element:",last_element)
print("--------------------------------")
# This tensor looks like an Matrix.
tensor_TwoDimensionMatrix = np.array([[1, 2],[3, 4]])
# Access matrix elements by index
print(tensor_TwoDimensionMatrix)
print("--------------------------------")
print(tensor_TwoDimensionMatrix[0][0])
print(tensor_TwoDimensionMatrix[1][0])
print(tensor_TwoDimensionMatrix[0][1])
print(tensor_TwoDimensionMatrix[1][1])
print("--------------------------------")
# print all elements of first Row and second Row
print("Print 1 row by [:][0]",tensor_TwoDimensionMatrix[:][0])
print("Print 2 row by [:][1]",tensor_TwoDimensionMatrix[:][0])
print("--------------------------------")
# print columen by
print("Print 1 row by [0][:]",tensor_TwoDimensionMatrix[:][0])
print("Print 2 row by [1][:]",tensor_TwoDimensionMatrix[:][0])
print("--------------------------------")
```

```
```

## Comments

## Post a Comment