Skip to content

Commit 1019954

Browse files
Remove upranking behavior from normalization
We would like normalization to be usable for unbatched multidimensional samples data in a dataset. This removes the automatic upranking of rank 0 and rank 1 inputs so this is possible. As a consequence, the default axis=-1 will treat rank 1 inputs as single samples, and normalize each dimension of the input individually. If you would like to pass batched or unbatched scalar data into the layer, and normalize every element, you should pass axis=None. PiperOrigin-RevId: 379868721
1 parent 1cbc25b commit 1019954

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

site/en/tutorials/structured_data/preprocessing_layers.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@
385385
"source": [
386386
"def get_normalization_layer(name, dataset):\n",
387387
" # Create a Normalization layer for our feature.\n",
388-
" normalizer = preprocessing.Normalization()\n",
388+
" normalizer = preprocessing.Normalization(axis=None)\n",
389389
"\n",
390390
" # Prepare a Dataset that only yields our feature.\n",
391391
" feature_ds = dataset.map(lambda x, y: x[name])\n",

0 commit comments

Comments
 (0)