Tensorflow 2 – One Hot Encoding Examples

September 2, 2021 A Goodman

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

September 2, 2021 Guest Contributor

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

September 2, 2021 Guest Contributor

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

August 30, 2021 A Goodman

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

August 30, 2021 A Goodman

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

August 24, 2021 Guest Contributor

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

August 24, 2021 A Goodman

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

August 23, 2021 Guest Contributor

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

August 23, 2021 Guest Contributor

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

August 17, 2021 A Goodman

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!

Tensorflow 2: Convert Arrays to Tensors (2 Examples)

August 17, 2021 A Goodman

A tensor is a multi-dimensional array with a uniform type. It is the standard data format used in Tensorflow. Below are a few examples of creating tensors from Numpy arrays by using tf.convert_to_tensor and tf.constant functions….

Useful Settings for Google Colab You Should Know

May 19, 2021 A Goodman

This article will introduce you to some useful tips when writing and running code on Google Colab. Your work and research will be a little faster, a little more comfortable, a little more pleasant. Dark Mode…

1 2