tensorflow / tfjs

A WebGL accelerated JavaScript library for training and deploying ML models.
https://js.tensorflow.org
Apache License 2.0
18.49k stars 1.93k forks source link

MnistData is not defined #8336

Closed mwy189 closed 3 months ago

gaikwadrahul8 commented 3 months ago

Hi, @mwy189

Thank you for bringing this issue to our attention and if you're following this TensorFlow.js — Handwritten digit recognition with CNNs codelab tutorial then you're getting MnistData is not defined issue then please comment this line import * as tf from '@tensorflow/tfjs'; from data.js file and follow the rest of the steps from codelab tutorial as mentioned and it should work as expected.

In this tutorial you will be training a model to learn to recognize digits in images like the ones below. These images are 28x28px greyscale images from a dataset called MNIST.

We have provided code to load these images from a special sprite file (~10MB) that we have created for you so that we can focus on the training portion.

Feel free to study the data.js file to understand how the data is loaded. Or once you are done with this tutorial, create your own approach to loading the data.

The provided code contains a class MnistData that has two public methods:

nextTrainBatch(batchSize): returns a random batch of images and their labels from the training set.
nextTestBatch(batchSize): returns a batch of images and their labels from the test set

The MnistData class also does the important steps of shuffling and normalizing the data.

NOTE: It's using the older versions of @tensorflow/tfjs and tfjs-vis so I tried with latest versions and it's working as expected so just replace below code snippet with older in index.html

<!-- Import TensorFlow.js -->
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@4.20.0/dist/tf.min.js"></script>

 <!-- Import tfjs-vis -->
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-vis@1.5.1/dist/tfjs-vis.umd.min.js"></script>

Here is output screenshot for reference : image

If I have missed something here please let me know with more description to address your issue from our end.

Thank you for your cooperation and patience.

mwy189 commented 3 months ago

您好,      您的邮件已经收到,感谢您付出的宝贵时间,我将会尽快查看邮件,若为急件,还请致电或短信通知。      辛苦了~ 谢谢。

gaikwadrahul8 commented 3 months ago

Hi, @mwy189

To confirm, have you had a chance to test the provided workaround in my previous comment to verify things are functioning as intended?

If the functionality meets expectations, please feel free to close this issue. However, if the issue persists, kindly provide an error log for further investigation on our end.

Thank you for your cooperation and patience.

mwy189 commented 3 months ago

thank you

gaikwadrahul8 commented 3 months ago

Hi, @mwy189

You're welcome and if your issue has been resolved please feel free to close this issue from your end and if you need any further assistance with TensorFlow.js in future please feel free to create new issue by following our issue template. We will be happy to help you

Thank you for your cooperation and patience.

gaikwadrahul8 commented 3 months ago

Hi, @mwy189

We haven't got confirmation from your end so now I'm closing this issue and if you need any further assistance with TensorFlow.js in future please feel free to create new issue by following our issue template. We will be happy to help you

Thank you for your cooperation and patience.

google-ml-butler[bot] commented 3 months ago

Are you satisfied with the resolution of your issue? Yes No