## How to see your Tensorflow version

TL;DR: You can check the version of Tensorflow that you are working with by using the __version__ attribute. Example After executing the preceding code, you will get a result similar to this: Further reading Tensorflow 2…

## How to Install Python Libraries in Google Colab

When using Google Colab, you can install a Python library by running the following: If you want to work with a specific version of a package: In case you wish to upgrade a module to the…

## Tensorflow 2 – One Hot Encoding Examples

In simple words, one hot encoding means converting categorical variables into a form that could be taken by a machine learning algorithm for more effective prediction. In Tensorflow 2, you can do one-hot encoding by using…

## Tensorflow 2 – Removing all Single Dimensions from a Tensor

In Tensorflow 2, you can remove all size 1 dimensions from a given tensor by using the tf.squeeze function. Example: Output: You can find more information about the mentioned function in Tensorflow’s official docs. Further reading:…

## Tensorflow 2 – Get the Indices of Min and Max in a Tensor

In Tensorflow 2, you can get the indices of the minimum and maximum values in a given tensor by using the tf.argmin and tf.argmax functions, respectively. Example: Output: Further reading: Tensorflow 2 – Aggregation Operators on…

## Tensorflow 2 – Aggregation Operators on Tensors

In simple words, aggregating means condensing the from multiple values down to a smaller amount of values. You can find a more formal definition in the Cambridge dictionary or Merriam Webster dictionary. This article shows you…

## Tensorflow 2 – Changing the Datatype of a Tensor

In Tensorflow 2, you can cast the datatype of a tensor to a new datatype by using the tf.cast function. The examples below will show you more clearly. Example 1 The code: Output: Example 2 The…

## Tensorflow 2 – Arithmetic Operations on Tensors

This guide shows you how to perform the four arithmetic operations on tensors in Tensorflow 2: addition, subtraction, multiplication, and division. Addition You can add values to a tensor using the Python math addition operator or…

## 2 Ways to Expand a Tensor in Tensorflow 2

Expanding a tensor means adding a dimension (or an axis) to it. The two examples below show you two different ways to expand a tenor in Tensorflow 2. Example 1: Using tf.newaxis The code: Output: Example…

## 3 Ways to Create Random Tensors in Tensorflow 2

This article shows you a couple of different ways to create random tensors with Tensorflow 2. Using tf.random.Generator Example: Output: Shuffling the Order of Elements in a Tensor Another technique to produce a random tensor is…

## Tensorflow 2 – Using tf.Variable examples

Below are some practical examples of using tf.Variable, which can help you create modifiable tensors in Tensorflow 2. Example 1: Creating a New Variable and Assigning New Value The code: Output: Example 2: Adding/Subtracting Value The…

## Tensorflow – Converting Tensors to Numpy Arrays

You can convert a tensor to a numpy array with ease by using the tensor.numpy() method or the np.array() function. Example: Output: Hope this helps!