Skip to content

Commit d8930ca

Browse files
Merge pull request #2316 from jperk224:patch-1
PiperOrigin-RevId: 684927870
2 parents a45eae2 + d135e81 commit d8930ca

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

site/en/tutorials/keras/regression.ipynb

+3-1
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@
252252
"source": [
253253
"The `\"Origin\"` column is categorical, not numeric. So the next step is to one-hot encode the values in the column with [pd.get_dummies](https://pandas.pydata.org/docs/reference/api/pandas.get_dummies.html).\n",
254254
"\n",
255+
"Neglecting to specify a data type by way of a `dtype` argument will leave you with boolean values, causing errors during normalization when instantiating the Tensor object if the feature values are not cast to a uniform type when passing the array into `tf.keras.layers.Normalization.adapt()`. [Tensor objects](https://www.tensorflow.org/guide/tensor) must house uniform data types.\n",
256+
"\n",
255257
"Note: You can set up the `tf.keras.Model` to do this kind of transformation for you but that's beyond the scope of this tutorial. Check out the [Classify structured data using Keras preprocessing layers](../structured_data/preprocessing_layers.ipynb) or [Load CSV data](../load_data/csv.ipynb) tutorials for examples."
256258
]
257259
},
@@ -274,7 +276,7 @@
274276
},
275277
"outputs": [],
276278
"source": [
277-
"dataset = pd.get_dummies(dataset, columns=['Origin'], prefix='', prefix_sep='')\n",
279+
"dataset = pd.get_dummies(dataset, columns=['Origin'], prefix='', prefix_sep='', dtype=float)\n",
278280
"dataset.tail()"
279281
]
280282
},

0 commit comments

Comments
 (0)