From 7b5d47fe6b049763d0604f9a0a63476e65edd990 Mon Sep 17 00:00:00 2001 From: Jihun Han <1155128719@link.cuhk.edu.hk> Date: Sun, 12 Mar 2023 23:35:22 +0900 Subject: [PATCH 1/2] fix minor typo on the image segmentation tutorial Just found that tf.keras.losses.CategoricalCrossentropy should be changed to tf.keras.losses.SparseCategoricalCrossentropy since the pixel classes (labels) are integers, not one-hot encoded. Code is written correct, but the markdown should fix to prevent potential confusion to readers. --- site/en/tutorials/images/segmentation.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/en/tutorials/images/segmentation.ipynb b/site/en/tutorials/images/segmentation.ipynb index 86b3f6f61bd..c2b96d5f6a7 100644 --- a/site/en/tutorials/images/segmentation.ipynb +++ b/site/en/tutorials/images/segmentation.ipynb @@ -452,7 +452,7 @@ "\n", "Now, all that is left to do is to compile and train the model. \n", "\n", - "Since this is a multiclass classification problem, use the `tf.keras.losses.CategoricalCrossentropy` loss function with the `from_logits` argument set to `True`, since the labels are scalar integers instead of vectors of scores for each pixel of every class.\n", + "Since this is a multiclass classification problem, use the `tf.keras.losses.SparseCategoricalCrossentropy` loss function with the `from_logits` argument set to `True`, since the labels are scalar integers instead of vectors of scores for each pixel of every class.\n", "\n", "When running inference, the label assigned to the pixel is the channel with the highest value. This is what the `create_mask` function is doing." ] From 9e2b9ae651b991afd135a59bb56a61650c1cdc15 Mon Sep 17 00:00:00 2001 From: Jihun Han <1155128719@link.cuhk.edu.hk> Date: Fri, 17 Mar 2023 17:25:42 +0900 Subject: [PATCH 2/2] update minor punctuation errors --- site/en/tutorials/images/segmentation.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/site/en/tutorials/images/segmentation.ipynb b/site/en/tutorials/images/segmentation.ipynb index c2b96d5f6a7..4bf59cbbd5a 100644 --- a/site/en/tutorials/images/segmentation.ipynb +++ b/site/en/tutorials/images/segmentation.ipynb @@ -710,7 +710,7 @@ "id": "Gbwo3DZ-9TxM" }, "source": [ - "So, to make sample weights for this tutorial, you need a function that takes a `(data, label)` pair and returns a `(data, label, sample_weight)` triple. Where the `sample_weight` is a 1-channel image containing the class weight for each pixel.\n", + "So, to make sample weights for this tutorial, you need a function that takes a `(data, label)` pair and returns a `(data, label, sample_weight)` triple where the `sample_weight` is a 1-channel image containing the class weight for each pixel.\n", "\n", "The simplest possible implementation is to use the label as an index into a `class_weight` list:" ] @@ -804,7 +804,7 @@ "\n", "Now that you have an understanding of what image segmentation is and how it works, you can try this tutorial out with different intermediate layer outputs, or even different pretrained models. You may also challenge yourself by trying out the [Carvana](https://www.kaggle.com/c/carvana-image-masking-challenge/overview) image masking challenge hosted on Kaggle.\n", "\n", - "You may also want to see the [Tensorflow Object Detection API](https://github.com/tensorflow/models/blob/master/research/object_detection/README.md) for another model you can retrain on your own data. Pretrained models are available on [TensorFlow Hub](https://www.tensorflow.org/hub/tutorials/tf2_object_detection#optional)" + "You may also want to see the [Tensorflow Object Detection API](https://github.com/tensorflow/models/blob/master/research/object_detection/README.md) for another model you can retrain on your own data. Pretrained models are available on [TensorFlow Hub](https://www.tensorflow.org/hub/tutorials/tf2_object_detection#optional)." ] } ],