Skip to content

Commit d03b888

Browse files
committed
Fix typos in KerasHub getting started guide
1 parent 7844afa commit d03b888

File tree

3 files changed

+31
-33
lines changed

3 files changed

+31
-33
lines changed

guides/ipynb/keras_hub/getting_started.ipynb

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
"\n",
114114
"1. Go to the [Gemma 2](https://www.kaggle.com/models/keras/gemma2) model page, and accept\n",
115115
" the license at the banner at the top.\n",
116-
"2. Generate an Kaggle API key by going to [Kaggle settings](https://www.kaggle.com/settings)\n",
116+
"2. Generate a Kaggle API key by going to [Kaggle settings](https://www.kaggle.com/settings)\n",
117117
" and clicking \"Create New Token\" button under the \"API\" section.\n",
118118
"3. Inside your colab notebook, click on the key icon on the left hand toolbar. Add two\n",
119119
" secrets: `KAGGLE_USERNAME` with your username, and `KAGGLE_KEY` with the API key you just\n",
@@ -169,7 +169,7 @@
169169
" range, or resizing inputs to a specific size. This class encapsulates the image-specific\n",
170170
" preprocessing.\n",
171171
" * **Inherits from**: `keras.layers.Layer`.\n",
172-
"* **AudioConveter**: `keras_hub.layers.AudioConveter`.\n",
172+
"* **AudioConverter**: `keras_hub.layers.AudioConverter`.\n",
173173
" * **What it does**: Converts raw audio to model ready input.\n",
174174
" * **Why it's important**: Audio models often need to preprocess raw audio input before\n",
175175
" passing it to a model, e.g. by computing a spectrogram of the audio signal. This class\n",
@@ -181,7 +181,7 @@
181181
"`keras_hub.tokenizers.Tokenizer.from_preset(\"gemma2_2b_en\")` will create a layer that\n",
182182
"tokenizes text using a Gemma2 tokenizer vocabulary.\n",
183183
"\n",
184-
"The figure below shows how all these core classes interact. Arrow indicate composition\n",
184+
"The figure below shows how all these core classes interact. Arrows indicate composition\n",
185185
"not inheritance (e.g., a task *has a* backbone).\n",
186186
"\n",
187187
"![png](/img/guides/getting_started/class-diagram.png)"
@@ -294,7 +294,7 @@
294294
"can view the full list of models shipped directly by the Keras team on\n",
295295
"[Kaggle](https://www.kaggle.com/organizations/keras/models).\n",
296296
"\n",
297-
"A task is just a subclass of `keras.Model` \u2014 you can use `fit()`, `compile()`, and\n",
297+
"A task is just a subclass of `keras.Model` you can use `fit()`, `compile()`, and\n",
298298
"`save()` on our `classifier` object same as any other model. But tasks come with a few\n",
299299
"extras provided by the KerasHub library. The first and most important is `from_preset()`,\n",
300300
"a special constructor you will see on many classes in KerasHub.\n",
@@ -320,7 +320,7 @@
320320
"specific outputs, depending on what we are trying to do with the model.\n",
321321
"\n",
322322
"A **preprocessor** is just a Keras layer that does all the preprocessing for a specific\n",
323-
"task. In our case, preprocessing with will resize our input image and rescale it to the\n",
323+
"task. In our case, preprocessing will resize our input image and rescale it to the\n",
324324
"range `[0, 1]` using some ImageNet specific mean and variance data. Let's call our\n",
325325
"task's preprocessor and backbone in succession to see what happens to our input shape."
326326
]
@@ -347,7 +347,7 @@
347347
},
348348
"source": [
349349
"Our raw image is rescaled to `(224, 224)` during preprocessing and finally\n",
350-
"downscaled to a `(7, 7)` image of 2048 feature vectors \u2014 the latent space of the\n",
350+
"downscaled to a `(7, 7)` image of 2048 feature vectors the latent space of the\n",
351351
"ResNet model. Note that ResNet can actually handle images of arbitrary sizes,\n",
352352
"though performance will eventually fall off if your image is very different\n",
353353
"sized than the pretrained data. If you'd like to disable the resizing in the\n",
@@ -562,7 +562,7 @@
562562
"The net effect is that we will explore our model's distribution much more broadly each\n",
563563
"time we generate output. Generation will now be a random process, each time we re-run\n",
564564
"generate we will get a different result. We can note that the results feel \"looser\" than\n",
565-
"greedy search \u2014 more minor mistakes and a less consistent tone.\n",
565+
"greedy search more minor mistakes and a less consistent tone.\n",
566566
"\n",
567567
"You can look at all the samplers Keras supports at [keras_hub.samplers](https://keras.io/api/keras_hub/samplers/).\n",
568568
"\n",
@@ -841,8 +841,8 @@
841841
"Huggingface models hub and share them with others. `keras_hub.upload_preset` allows you\n",
842842
"to upload a saved preset.\n",
843843
"\n",
844-
"In this case, we will upload to Kaggle. We have already authenticated with Kaggle to,\n",
845-
"download the Gemma model earlier. Running the following cell well upload a new model\n",
844+
"In this case, we will upload to Kaggle. We have already authenticated with Kaggle to\n",
845+
"download the Gemma model earlier. Running the following cell will upload a new model\n",
846846
"to Kaggle."
847847
]
848848
},
@@ -980,7 +980,7 @@
980980
"colab_type": "text"
981981
},
982982
"source": [
983-
"The IMDb dataset contrains a large amount of unlabeled movie reviews. We don't need those\n",
983+
"The IMDb dataset contains a large amount of unlabeled movie reviews. We don't need those\n",
984984
"here, we can simply delete them."
985985
]
986986
},
@@ -1119,8 +1119,7 @@
11191119
" \"token_ids\": x,\n",
11201120
" \"padding_mask\": x != tokenizer.pad_token_id,\n",
11211121
" }\n",
1122-
" return keras.utils.pack_x_y_sample_weight(x, y)\n",
1123-
""
1122+
" return keras.utils.pack_x_y_sample_weight(x, y)\n"
11241123
]
11251124
},
11261125
{
@@ -1185,7 +1184,7 @@
11851184
"\n",
11861185
"Since the Gemma model is a generative model, information only passed from left to right\n",
11871186
"in the sequence. The only token representation that can \"see\" the entire movie review\n",
1188-
"input is the final token in each review. We can write a simple pooling layer to do this \u2014\n",
1187+
"input is the final token in each review. We can write a simple pooling layer to do this \n",
11891188
"we will simply grab the last non-padding position of each input sequence. There's no special\n",
11901189
"process to writing a layer like this, we can use Keras and `keras.ops` normally."
11911190
]
@@ -1206,8 +1205,7 @@
12061205
" end_positions = ops.sum(padding_mask, axis=1, keepdims=True) - 1\n",
12071206
" end_positions = ops.cast(end_positions, \"int\")[:, :, None]\n",
12081207
" outputs = ops.take_along_axis(inputs, end_positions, axis=1)\n",
1209-
" return ops.squeeze(outputs, axis=1)\n",
1210-
""
1208+
" return ops.squeeze(outputs, axis=1)\n"
12111209
]
12121210
},
12131211
{
@@ -1291,7 +1289,7 @@
12911289
"colab_type": "text"
12921290
},
12931291
"source": [
1294-
"After enabling LoRA, our model goes from 10GB of traininable parameters to just 20MB.\n",
1292+
"After enabling LoRA, our model goes from 10GB of trainable parameters to just 20MB.\n",
12951293
"That means the space used by optimizer variables will no longer be a concern.\n",
12961294
"\n",
12971295
"With all that set up, we can compile and train our model as normal."
@@ -1390,4 +1388,4 @@
13901388
},
13911389
"nbformat": 4,
13921390
"nbformat_minor": 0
1393-
}
1391+
}

guides/keras_hub/getting_started.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
6666
1. Go to the [Gemma 2](https://www.kaggle.com/models/keras/gemma2) model page, and accept
6767
the license at the banner at the top.
68-
2. Generate an Kaggle API key by going to [Kaggle settings](https://www.kaggle.com/settings)
68+
2. Generate a Kaggle API key by going to [Kaggle settings](https://www.kaggle.com/settings)
6969
and clicking "Create New Token" button under the "API" section.
7070
3. Inside your colab notebook, click on the key icon on the left hand toolbar. Add two
7171
secrets: `KAGGLE_USERNAME` with your username, and `KAGGLE_KEY` with the API key you just
@@ -116,7 +116,7 @@
116116
range, or resizing inputs to a specific size. This class encapsulates the image-specific
117117
preprocessing.
118118
* **Inherits from**: `keras.layers.Layer`.
119-
* **AudioConveter**: `keras_hub.layers.AudioConveter`.
119+
* **AudioConverter**: `keras_hub.layers.AudioConverter`.
120120
* **What it does**: Converts raw audio to model ready input.
121121
* **Why it's important**: Audio models often need to preprocess raw audio input before
122122
passing it to a model, e.g. by computing a spectrogram of the audio signal. This class
@@ -128,7 +128,7 @@
128128
`keras_hub.tokenizers.Tokenizer.from_preset("gemma2_2b_en")` will create a layer that
129129
tokenizes text using a Gemma2 tokenizer vocabulary.
130130
131-
The figure below shows how all these core classes interact. Arrow indicate composition
131+
The figure below shows how all these core classes interact. Arrows indicate composition
132132
not inheritance (e.g., a task *has a* backbone).
133133
134134
![png](/img/guides/getting_started/class-diagram.png)
@@ -215,7 +215,7 @@
215215
specific outputs, depending on what we are trying to do with the model.
216216
217217
A **preprocessor** is just a Keras layer that does all the preprocessing for a specific
218-
task. In our case, preprocessing with will resize our input image and rescale it to the
218+
task. In our case, preprocessing will resize our input image and rescale it to the
219219
range `[0, 1]` using some ImageNet specific mean and variance data. Let's call our
220220
task's preprocessor and backbone in succession to see what happens to our input shape.
221221
"""
@@ -488,8 +488,8 @@
488488
Huggingface models hub and share them with others. `keras_hub.upload_preset` allows you
489489
to upload a saved preset.
490490
491-
In this case, we will upload to Kaggle. We have already authenticated with Kaggle to,
492-
download the Gemma model earlier. Running the following cell well upload a new model
491+
In this case, we will upload to Kaggle. We have already authenticated with Kaggle to
492+
download the Gemma model earlier. Running the following cell will upload a new model
493493
to Kaggle.
494494
"""
495495

@@ -552,7 +552,7 @@
552552
data_dir = pathlib.Path(extract_dir) / "aclImdb"
553553

554554
"""
555-
The IMDb dataset contrains a large amount of unlabeled movie reviews. We don't need those
555+
The IMDb dataset contains a large amount of unlabeled movie reviews. We don't need those
556556
here, we can simply delete them.
557557
"""
558558

@@ -737,7 +737,7 @@ def call(self, inputs, padding_mask):
737737
text_classifier.summary()
738738

739739
"""
740-
After enabling LoRA, our model goes from 10GB of traininable parameters to just 20MB.
740+
After enabling LoRA, our model goes from 10GB of trainable parameters to just 20MB.
741741
That means the space used by optimizer variables will no longer be a concern.
742742
743743
With all that set up, we can compile and train our model as normal.

guides/md/keras_hub/getting_started.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ guide, so we can follow the following steps:
6464

6565
1. Go to the [Gemma 2](https://www.kaggle.com/models/keras/gemma2) model page, and accept
6666
the license at the banner at the top.
67-
2. Generate an Kaggle API key by going to [Kaggle settings](https://www.kaggle.com/settings)
67+
2. Generate a Kaggle API key by going to [Kaggle settings](https://www.kaggle.com/settings)
6868
and clicking "Create New Token" button under the "API" section.
6969
3. Inside your colab notebook, click on the key icon on the left hand toolbar. Add two
7070
secrets: `KAGGLE_USERNAME` with your username, and `KAGGLE_KEY` with the API key you just
@@ -114,7 +114,7 @@ Before we begin, let's take a look at the key classes we will use in the KerasHu
114114
range, or resizing inputs to a specific size. This class encapsulates the image-specific
115115
preprocessing.
116116
* **Inherits from**: `keras.layers.Layer`.
117-
* **AudioConveter**: `keras_hub.layers.AudioConveter`.
117+
* **AudioConverter**: `keras_hub.layers.AudioConverter`.
118118
* **What it does**: Converts raw audio to model ready input.
119119
* **Why it's important**: Audio models often need to preprocess raw audio input before
120120
passing it to a model, e.g. by computing a spectrogram of the audio signal. This class
@@ -126,7 +126,7 @@ the component with weights and state for the given pre-trained model identifier.
126126
`keras_hub.tokenizers.Tokenizer.from_preset("gemma2_2b_en")` will create a layer that
127127
tokenizes text using a Gemma2 tokenizer vocabulary.
128128

129-
The figure below shows how all these core classes interact. Arrow indicate composition
129+
The figure below shows how all these core classes interact. Arrows indicate composition
130130
not inheritance (e.g., a task *has a* backbone).
131131

132132
![png](/img/guides/getting_started/class-diagram.png)
@@ -236,7 +236,7 @@ pretrained model's latent space. We can then map this latent space to any number
236236
specific outputs, depending on what we are trying to do with the model.
237237

238238
A **preprocessor** is just a Keras layer that does all the preprocessing for a specific
239-
task. In our case, preprocessing with will resize our input image and rescale it to the
239+
task. In our case, preprocessing will resize our input image and rescale it to the
240240
range `[0, 1]` using some ImageNet specific mean and variance data. Let's call our
241241
task's preprocessor and backbone in succession to see what happens to our input shape.
242242

@@ -805,8 +805,8 @@ One of the most powerful features of KerasHub is the ability upload models to Ka
805805
Huggingface models hub and share them with others. `keras_hub.upload_preset` allows you
806806
to upload a saved preset.
807807

808-
In this case, we will upload to Kaggle. We have already authenticated with Kaggle to,
809-
download the Gemma model earlier. Running the following cell well upload a new model
808+
In this case, we will upload to Kaggle. We have already authenticated with Kaggle to
809+
download the Gemma model earlier. Running the following cell will upload a new model
810810
to Kaggle.
811811

812812

@@ -901,7 +901,7 @@ extract_dir = keras.utils.get_file(
901901
data_dir = pathlib.Path(extract_dir) / "aclImdb"
902902
```
903903

904-
The IMDb dataset contrains a large amount of unlabeled movie reviews. We don't need those
904+
The IMDb dataset contains a large amount of unlabeled movie reviews. We don't need those
905905
here, we can simply delete them.
906906

907907

@@ -1223,7 +1223,7 @@ text_classifier.summary()
12231223

12241224

12251225

1226-
After enabling LoRA, our model goes from 10GB of traininable parameters to just 20MB.
1226+
After enabling LoRA, our model goes from 10GB of trainable parameters to just 20MB.
12271227
That means the space used by optimizer variables will no longer be a concern.
12281228

12291229
With all that set up, we can compile and train our model as normal.

0 commit comments

Comments
 (0)