1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to TensorFlow in Python

Exercise

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.

This image shows four feature columns from a dataset on credit card default: education, marriage, age, and bill amount.

Instructions

100 XP
  • Import the constant submodule from the tensorflow module.
  • Convert the credit_numpy array into a constant object in tensorflow. Do not set the data type.