{"id":19195063,"url":"https://github.com/ksachdeva/tfjs-data-mnist","last_synced_at":"2025-05-08T23:01:34.900Z","repository":{"id":136497964,"uuid":"160018740","full_name":"ksachdeva/tfjs-data-mnist","owner":"ksachdeva","description":"API for MNIST dataset built using tfjs-data","archived":false,"fork":false,"pushed_at":"2018-12-10T23:52:32.000Z","size":233,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-19T07:59:35.577Z","etag":null,"topics":["dataset","mnist","tensorflow","tfjs","tfjs-data"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ksachdeva.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-12-02T06:02:37.000Z","updated_at":"2021-03-30T19:32:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"adbe2bec-72b4-4336-9fb3-8ea969b02196","html_url":"https://github.com/ksachdeva/tfjs-data-mnist","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ksachdeva%2Ftfjs-data-mnist","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ksachdeva%2Ftfjs-data-mnist/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ksachdeva%2Ftfjs-data-mnist/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ksachdeva%2Ftfjs-data-mnist/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ksachdeva","download_url":"https://codeload.github.com/ksachdeva/tfjs-data-mnist/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253160764,"owners_count":21863627,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dataset","mnist","tensorflow","tfjs","tfjs-data"],"created_at":"2024-11-09T12:08:14.215Z","updated_at":"2025-05-08T23:01:34.894Z","avatar_url":"https://github.com/ksachdeva.png","language":"TypeScript","readme":"# Dataset API (tfjs-data) for MNIST\n\nThis package provides the Dataset API for MNIST dataset. It is built using [@tensorflow/tfjs-data](https://github.com/tensorflow/tfjs-data) package (which is now\nincluded in [@tensorflow/tfjs](https://github.com/tensorflow/tfjs) union package) that provides a uniform and consistent way to access various datasets.\n\n## Installation\n\nnpm install tfjs-data-mnist\n\n## Usage\n\n```ts\n// get the dataset\nconst ds = await MNISTDataset.create();\n\n// there are 2 properties in ds (testDataset and trainDataset)\n\n// get the iterator for testDataset\nconst it = await ds.testDataset.iterator();\n\n// iterate by invoking next\nconst dataElement =  await it.next();\n\n// dataElement.done === true =\u003e there are no more elements \n\n// dataElement.value is **TensorContainer** of type [feature, label]\n// where feature and label are of type Tensor1D\n//\n// feature is Tensor1D with shape [784]\n// label is Tensor1D with shape [10]\n//\n//\n// label is actually a one-hot encoded vector\n\n// how to get the feature and label\nconst feature = dataElement.value[0] as tfjs.Tensor;\nconst label = dataElement.value[1] as tfjs.Tensor;\n\n// The nice thing about dataset API is that you get\n// lot of operations such as suffle, repeat, take etc\n// for free\n\n// Here is an example to first shuffle the dataset\n// and then take only first 5 samples\n\nconst shuffled5 = await ds.testDataset.shuffle(10).take(5).iterator();\n\n// You can also pass dataset to train the model\nawait model.fitDataset(ds.trainDataset.batch(32), {\n    epochs: 1,\n    callbacks: {\n      onBatchEnd: async (batch: number, logs?: tf.Logs) =\u003e {\n        batchProgressEl.innerText =\n            `${batch} - ${logs['loss']} -  ${logs['acc']}`;\n      },\n      onEpochEnd: async (epoch: number, logs?: tf.Logs) =\u003e {\n        epochEndResultEl.innerText =\n            `${epoch} - ${logs['loss']} -  ${logs['acc']}`;\n      }\n    }\n  });\n\n```\n\n## Examples\n\n### Running the samples\n\n```bash\n\n# do npm install at the root of this directory\nnpm install\n\n# install peer dependnencies\nnpm install @tensorflow/tfjs-core @tensorflow/tfjs-data --no-save\n\n# change directory into example\ncd examples\n\n# do npm install in example\nnpm install\n\n# Run a basic example that shows\n# how to use the api of Dataset\nnpm run basic\n\n# Another example is to train a model\n# where I use fitDataset api that takes Dataset\n# as an input\nnpm run train\n\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fksachdeva%2Ftfjs-data-mnist","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fksachdeva%2Ftfjs-data-mnist","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fksachdeva%2Ftfjs-data-mnist/lists"}