Skip to content

Commit b226417

Browse files
authored
Update and lint the Transfer Learning with YAMNet tutorial
1 parent df075be commit b226417

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

site/en/tutorials/audio/transfer_learning_audio.ipynb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@
6262
"id": "K2madPFAGHb3"
6363
},
6464
"source": [
65-
"# Transfer Learning with YAMNet for environmental sound classification\n",
65+
"# Transfer learning with YAMNet for environmental sound classification\n",
6666
"\n",
67-
"[YAMNet](https://tfhub.dev/google/yamnet/1) is a pre-trained deep neural network that can predict audio events from [521 classes](https://github.com/tensorflow/models/blob/master/research/audioset/yamnet/yamnet_class_map.csv), like laughter, barking, or a siren. \n",
67+
"[YAMNet](https://tfhub.dev/google/yamnet/1) is a pre-trained deep neural network that can predict audio events from [521 classes](https://github.com/tensorflow/models/blob/master/research/audioset/yamnet/yamnet_class_map.csv), such as laughter, barking, or a siren. \n",
6868
"\n",
6969
" In this tutorial you will learn how to:\n",
7070
"\n",
@@ -130,15 +130,15 @@
130130
"source": [
131131
"## About YAMNet\n",
132132
"\n",
133-
"[YAMNet](https://github.com/tensorflow/models/tree/master/research/audioset/yamnet) is a pre-trained neural network that employs the [MobileNetV1](https://arxiv.org/abs/1704.04861) depthwise-separable convolution architecture. It can use an audio waveform as input and classify 521 audio events from the [AudioSet](http://g.co/audioset) corpus.\n",
133+
"[YAMNet](https://github.com/tensorflow/models/tree/master/research/audioset/yamnet) is a pre-trained neural network that employs the [MobileNetV1](https://arxiv.org/abs/1704.04861) depthwise-separable convolution architecture. It can use an audio waveform as input and make independent predictions for each of the 521 audio events from the [AudioSet](http://g.co/audioset) corpus.\n",
134134
"\n",
135135
"Internally, the model extracts \"frames\" from the audio signal and processes batches of these frames. This version of the model uses frames that are 0.96 second long and extracts one frame every 0.48 second.\n",
136136
"\n",
137137
"The model accepts a 1-D float32 Tensor or NumPy array containing a waveform of arbitrary length, represented as single-channel (mono) 16 kHz samples in the range `[-1.0, +1.0]`. This tutorial contains code to help you convert WAV files into the supported format.\n",
138138
"\n",
139139
"The model returns 3 outputs, including the class scores, embeddings (which you will use for transfer learning), and the log mel [spectrogram](https://www.tensorflow.org/tutorials/audio/simple_audio#spectrogram). You can find more details [here](https://tfhub.dev/google/yamnet/1).\n",
140140
"\n",
141-
"One specific use of YAMNet is as a high-level feature extractor - the 1,024-dimensional embedding output. You will use the base (YAMNet) model's input features and feed them into your shallower model consisting of one hidden [Dense](https://www.tensorflow.org/api_docs/python/tf/keras/layers/Dense) layer. Then, you will train the network on a small amount of data for audio classification _without_ requiring a lot of labeled data and training end-to-end. (This is similar to [transfer learning for image classification with TensorFlow Hub](https://www.tensorflow.org/tutorials/images/transfer_learning_with_hub) for more information.)\n",
141+
"One specific use of YAMNet is as a high-level feature extractor - the 1,024-dimensional embedding output. You will use the base (YAMNet) model's input features and feed them into your shallower model consisting of one hidden `tf.keras.layers.Dense` layer. Then, you will train the network on a small amount of data for audio classification _without_ requiring a lot of labeled data and training end-to-end. (This is similar to [transfer learning for image classification with TensorFlow Hub](https://www.tensorflow.org/tutorials/images/transfer_learning_with_hub) for more information.)\n",
142142
"\n",
143143
"First, you will test the model and see the results of classifying audio. You will then construct the data pre-processing pipeline.\n",
144144
"\n",
@@ -194,7 +194,7 @@
194194
"id": "mBm9y9iV2U_-"
195195
},
196196
"source": [
197-
"You will need a function to load audio files, which will also be used later when working with the training data. (Learn more about rading audio files and their labels in [Simple audio recognition](https://www.tensorflow.org/tutorials/audio/simple_audio#reading_audio_files_and_their_labels).\n",
197+
"You will need a function to load audio files, which will also be used later when working with the training data. (Learn more about reading audio files and their labels in [Simple audio recognition](https://www.tensorflow.org/tutorials/audio/simple_audio#reading_audio_files_and_their_labels).\n",
198198
"\n",
199199
"Note: The returned `wav_data` from `load_wav_16k_mono` is already normalized to values in the `[-1.0, 1.0]` range (for more information, go to [YAMNet's documentation on TF Hub](https://tfhub.dev/google/yamnet/1))."
200200
]
@@ -207,7 +207,7 @@
207207
},
208208
"outputs": [],
209209
"source": [
210-
"# Utility functions for loading audio files and ensure the correct sample rate\n",
210+
"# Utility functions for loading audio files and making sure the sample rate is correct.\n",
211211
"\n",
212212
"@tf.function\n",
213213
"def load_wav_16k_mono(filename):\n",
@@ -299,7 +299,7 @@
299299
"id": "YBaLNg5H5IWa"
300300
},
301301
"source": [
302-
"Note: The model correctly inferred an animal sound. Your goal in this tutorial is to increase the model's accuracy for specific classes. Also, notice that the the model generated 13 embeddings, 1 per frame."
302+
"Note: The model correctly inferred an animal sound. Your goal in this tutorial is to increase the model's accuracy for specific classes. Also, notice that the model generated 13 embeddings, 1 per frame."
303303
]
304304
},
305305
{
@@ -342,7 +342,7 @@
342342
"\n",
343343
"and all the audio files are in `./datasets/ESC-50-master/audio/`\n",
344344
"\n",
345-
"You will create a pandas DataFrame with the mapping and use that to have a clearer view of the data.\n"
345+
"You will create a pandas `DataFrame` with the mapping and use that to have a clearer view of the data.\n"
346346
]
347347
},
348348
{
@@ -368,7 +368,7 @@
368368
"source": [
369369
"### Filter the data\n",
370370
"\n",
371-
"Now that the data is tored in the DataFrame, apply some transformations:\n",
371+
"Now that the data is stored in the `DataFrame`, apply some transformations:\n",
372372
"\n",
373373
"- Filter out rows and use only the selected classes - `dog` and `cat`. If you want to use any other classes, this is where you can choose them.\n",
374374
"- Amend the filename to have the full path. This will make loading easier later.\n",
@@ -581,7 +581,7 @@
581581
"id": "OAbraYKYpdoE"
582582
},
583583
"source": [
584-
"Lets run the evaluate method on the test data just to be sure there's no overfitting."
584+
"Let's run the `evaluate` method on the test data just to be sure there's no overfitting."
585585
]
586586
},
587587
{
@@ -647,7 +647,7 @@
647647
"\n",
648648
"To do that, you will combine YAMNet with your model into a single model that you can export for other applications.\n",
649649
"\n",
650-
"To make it easier to use the model's result, the final layer will be a `reduce_mean` operation. When using this model for serving, as you will see bellow, you will need the name of the final layer. If you don't define one, TensorFlow will auto-define an incremental one that makes it hard to test, as it will keep changing every time you train the model. When using a raw TensorFlow operation, you can't assign a name to it. To address this issue, you'll create a custom layer that applies `reduce_mean` and call it `'classifier'`.\n"
650+
"To make it easier to use the model's result, the final layer will be a `reduce_mean` operation. When using this model for serving (which you will learn about later in the tutorial), you will need the name of the final layer. If you don't define one, TensorFlow will auto-define an incremental one that makes it hard to test, as it will keep changing every time you train the model. When using a raw TensorFlow operation, you can't assign a name to it. To address this issue, you'll create a custom layer that applies `reduce_mean` and call it `'classifier'`.\n"
651651
]
652652
},
653653
{

0 commit comments

Comments
 (0)