Setting the data type
In this exercise, you will both load data and set its type. Note that housing is available and pandas has been imported as pd. You will import numpy and tensorflow, and define tensors that are usable in tensorflow using columns in housing with a given data type. Recall that you can select the price column, for instance, from housing using housing['price'].
Diese Übung ist Teil des Kurses
Introduction to TensorFlow in Python
Anleitung zur Übung
- Import
numpyandtensorflowunder their standard aliases. - Use a
numpyarray to set the tensorpriceto have a data type of 32-bit floating point number - Use the
tensorflowfunctioncast()to set the tensorwaterfrontto have a Boolean data type. - Print
priceand thenwaterfront. Did you notice any important differences?
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
# Import numpy and tensorflow with their standard aliases
____
____
# Use a numpy array to define price as a 32-bit float
price = np.____(housing['price'], np.____)
# Define waterfront as a Boolean using cast
waterfront = tf.____(housing['waterfront'], tf.____)
# Print price and waterfront
print(____)
print(____)