Skip to content

Commit b7ac1a2

Browse files
Change Keras preprocessing APIs to stable in the Simple audio recognition tutorial
PiperOrigin-RevId: 405733610
1 parent bff734b commit b7ac1a2

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

site/en/tutorials/audio/simple_audio.ipynb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@
104104
"import seaborn as sns\n",
105105
"import tensorflow as tf\n",
106106
"\n",
107-
"from tensorflow.keras.layers.experimental import preprocessing\n",
108107
"from tensorflow.keras import layers\n",
109108
"from tensorflow.keras import models\n",
110109
"from IPython import display\n",
@@ -620,9 +619,9 @@
620619
},
621620
"source": [
622621
"For the model, you'll use a simple convolutional neural network (CNN), since you have transformed the audio files into spectrogram images.\n",
623-
"The model also has the following additional preprocessing layers:\n",
624-
"- A [`Resizing`](https://www.tensorflow.org/api_docs/python/tf/keras/layers/experimental/preprocessing/Resizing) layer to downsample the input to enable the model to train faster.\n",
625-
"- A [`Normalization`](https://www.tensorflow.org/api_docs/python/tf/keras/layers/experimental/preprocessing/Normalization) layer to normalize each pixel in the image based on its mean and standard deviation.\n",
622+
"The model also has the following additional Keras preprocessing layers:\n",
623+
"- `tf.keras.layers.Resizing`: to downsample the input to enable the model to train faster.\n",
624+
"- `tf.keras.layers.Normalization`: to normalize each pixel in the image based on its mean and standard deviation.\n",
626625
"\n",
627626
"For the `Normalization` layer, its `adapt` method would first need to be called on the training data in order to compute aggregate statistics (i.e. mean and standard deviation)."
628627
]
@@ -640,12 +639,12 @@
640639
"print('Input shape:', input_shape)\n",
641640
"num_labels = len(commands)\n",
642641
"\n",
643-
"norm_layer = preprocessing.Normalization()\n",
642+
"norm_layer = layers.Normalization()\n",
644643
"norm_layer.adapt(spectrogram_ds.map(lambda x, _: x))\n",
645644
"\n",
646645
"model = models.Sequential([\n",
647646
" layers.Input(shape=input_shape),\n",
648-
" preprocessing.Resizing(32, 32), \n",
647+
" layers.Resizing(32, 32), \n",
649648
" norm_layer,\n",
650649
" layers.Conv2D(32, 3, activation='relu'),\n",
651650
" layers.Conv2D(64, 3, activation='relu'),\n",

0 commit comments

Comments
 (0)