Defining data as constants
Throughout this course, we will use tensorflow
version 2.6.0 and will exclusively import the submodules needed to complete each exercise. This will usually be done for you, but you will do it in this exercise by importing constant
from tensorflow
.
After you have imported constant
, you will use it to transform a numpy
array, credit_numpy
, into a tensorflow
constant, credit_constant
. This array contains feature columns from a dataset on credit card holders and is previewed in the image below. We will return to this dataset in later chapters.
Note that tensorflow
2 allows you to use data as either a numpy
array or a tensorflow
constant
object. Using a constant
will ensure that any operations performed with that object are done in tensorflow
.
Diese Übung ist Teil des Kurses
Introduction to TensorFlow in Python
Anleitung zur Übung
- Import the
constant
submodule from thetensorflow
module. - Convert the
credit_numpy
array into aconstant
object intensorflow
. Do not set the data type.
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
# Import constant from TensorFlow
from tensorflow import ____
# Convert the credit_numpy array into a tensorflow constant
credit_constant = constant(____)
# Print constant datatype
print('\n The datatype is:', credit_constant.dtype)
# Print constant shape
print('\n The shape is:', credit_constant.shape)