始める無料で始める

データ型の設定

この演習では、データの読み込みと型の設定を行います。housing は利用可能で、pandaspd としてインポート済みです。numpytensorflow をインポートし、housing の列を使って、指定したデータ型を持つ tensorflow で利用できるテンソルを定義します。たとえば、housing['price'] のようにして housing から price 列を選択できることを思い出してください。

この演習はコースの一部です

Introduction to TensorFlow in Python

コースを見る

演習の手順

  • 標準のエイリアスで numpytensorflow をインポートします。
  • numpy 配列を使って、テンソル price のデータ型を 32 ビット浮動小数点数に設定します。
  • tensorflow の関数 cast() を使って、テンソル waterfront のデータ型をブール値に設定します。
  • price、続いて waterfront を出力してください。どんな重要な違いに気づきましたか?

実践的なインタラクティブ演習

このサンプルコードを完成させて、この演習に挑戦してみましょう。

# 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(____)
コードを編集して実行