LoslegenKostenlos loslegen

Defining variables

Unlike a constant, a variable's value can be modified. This will be useful when we want to train a model by updating its parameters.

Let's try defining and printing a variable. We'll then convert the variable to a numpy array, print again, and check for differences. Note that Variable(), which is used to create a variable tensor, has been imported from tensorflow and is available to use in the exercise.

Diese Übung ist Teil des Kurses

Introduction to TensorFlow in Python

Kurs anzeigen

Anleitung zur Übung

  • Define a variable, A1, as the 1-dimensional tensor: [1, 2, 3, 4].
  • Apply .numpy() to A1 and assign it to B1.

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

# Define the 1-dimensional variable A1
A1 = ____([1, 2, 3, 4])

# Print the variable A1
print('\n A1: ', A1)

# Convert A1 to a numpy array and assign it to B1
B1 = ____

# Print B1
print('\n B1: ', B1)
Code bearbeiten und ausführen