[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-3754":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":22,"archived":23,"fork":23,"defaultBranch":24,"hasWiki":25,"hasPages":25,"topics":26,"createdAt":10,"pushedAt":10,"updatedAt":37,"readmeContent":38,"aiSummary":39,"trendingCount":16,"starSnapshotCount":16,"syncStatus":40,"lastSyncTime":41,"discoverSource":42},3754,"tfjs","tensorflow\u002Ftfjs","tensorflow","A WebGL accelerated JavaScript library for training and deploying ML models.","https:\u002F\u002Fjs.tensorflow.org",null,"TypeScript",19128,2024,315,331,0,1,10,18,4,44.92,"Apache License 2.0",false,"master",true,[27,28,29,30,31,32,33,34,35,36],"deep-learning","deep-neural-network","gpu-acceleration","javascript","machine-learning","neural-network","typescript","wasm","web-assembly","webgl","2026-06-12 02:00:53","# TensorFlow.js\n\nTensorFlow.js is an open-source hardware-accelerated JavaScript library for\ntraining and deploying machine learning models.\n\n\n**Develop ML in the Browser** \u003Cbr\u002F>\nUse flexible and intuitive APIs to build models from scratch using the low-level\nJavaScript linear algebra library or the high-level layers API.\n\n**Develop ML in Node.js** \u003Cbr\u002F>\nExecute native TensorFlow with the same TensorFlow.js API under the Node.js\nruntime.\n\n**Run Existing models** \u003Cbr\u002F>\nUse TensorFlow.js model converters to run pre-existing TensorFlow models right\nin the browser.\n\n**Retrain Existing models** \u003Cbr\u002F>\nRetrain pre-existing ML models using sensor data connected to the browser or\nother client-side data.\n\n## About this repo\n\nThis repository contains the logic and scripts that combine\nseveral packages.\n\nAPIs:\n- [TensorFlow.js Core](\u002Ftfjs-core),\n  a flexible low-level API for neural networks and numerical computation.\n- [TensorFlow.js Layers](\u002Ftfjs-layers),\n  a high-level API which implements functionality similar to\n  [Keras](https:\u002F\u002Fkeras.io\u002F).\n- [TensorFlow.js Data](\u002Ftfjs-data),\n  a simple API to load and prepare data analogous to\n  [tf.data](https:\u002F\u002Fwww.tensorflow.org\u002Fguide\u002Fdatasets).\n- [TensorFlow.js Converter](\u002Ftfjs-converter),\n  tools to import a TensorFlow SavedModel to TensorFlow.js\n- [TensorFlow.js Vis](\u002Ftfjs-vis),\n  in-browser visualization for TensorFlow.js models\n- [TensorFlow.js AutoML](\u002Ftfjs-automl),\n  Set of APIs to load and run models produced by\n  [AutoML Edge](https:\u002F\u002Fcloud.google.com\u002Fvision\u002Fautoml\u002Fdocs\u002Fedge-quickstart).\n\n\nBackends\u002FPlatforms:\n- [TensorFlow.js CPU Backend](\u002Ftfjs-backend-cpu), pure-JS backend for Node.js and the browser.\n- [TensorFlow.js WebGL Backend](\u002Ftfjs-backend-webgl), WebGL backend for the browser.\n- [TensorFlow.js WASM Backend](\u002Ftfjs-backend-wasm), WebAssembly backend for the browser.\n- [TensorFlow.js WebGPU](\u002Ftfjs-backend-webgpu), WebGPU backend for the browser.\n- [TensorFlow.js Node](\u002Ftfjs-node), Node.js platform via TensorFlow C++ adapter.\n- [TensorFlow.js React Native](\u002Ftfjs-react-native), React Native platform via expo-gl adapter.\n\nIf you care about bundle size, you can import those packages individually.\n\nIf you are looking for Node.js support, check out the [TensorFlow.js Node directory](\u002Ftfjs-node).\n\n## Examples\n\nCheck out our\n[examples repository](https:\u002F\u002Fgithub.com\u002Ftensorflow\u002Ftfjs-examples)\nand our [tutorials](https:\u002F\u002Fjs.tensorflow.org\u002Ftutorials\u002F).\n\n## Gallery\n\nBe sure to check out [the gallery](GALLERY.md) of all projects related to TensorFlow.js.\n\n## Pre-trained models\n\nBe sure to also check out our [models repository](https:\u002F\u002Fgithub.com\u002Ftensorflow\u002Ftfjs-models) where we host pre-trained models\non NPM.\n\n## Benchmarks\n\n* [Local benchmark tool](https:\u002F\u002Ftfjs-benchmarks.web.app\u002F). Use this webpage tool to collect the performance related metrics (speed, memory, etc) of TensorFlow.js models and kernels **on your local device** with CPU, WebGL or WASM backends. You can benchmark custom models by following this [guide](https:\u002F\u002Fgithub.com\u002Ftensorflow\u002Ftfjs\u002Fblob\u002Fmaster\u002Fe2e\u002Fbenchmarks\u002Flocal-benchmark\u002FREADME.md).\n* [Multi-device benchmark tool](https:\u002F\u002Fgithub.com\u002Ftensorflow\u002Ftfjs\u002Ftree\u002Fmaster\u002Fe2e\u002Fbenchmarks\u002Fbrowserstack-benchmark\u002FREADME.md). Use this tool to collect the same performance related metrics **on a collection of remote devices**.\n\n## Getting started\n\nThere are two main ways to get TensorFlow.js in your JavaScript project:\nvia \u003Ca href=\"https:\u002F\u002Fdeveloper.mozilla.org\u002Fen-US\u002Fdocs\u002FLearn\u002FHTML\u002FHowto\u002FUse_JavaScript_within_a_webpage\" target=\"_blank\">script tags\u003C\u002Fa> \u003Cstrong>or\u003C\u002Fstrong> by installing it from \u003Ca href=\"https:\u002F\u002Fwww.npmjs.com\u002F\" target=\"_blank\">NPM\u003C\u002Fa>\nand using a build tool like \u003Ca href=\"https:\u002F\u002Fparceljs.org\u002F\" target=\"_blank\">Parcel\u003C\u002Fa>,\n\u003Ca href=\"https:\u002F\u002Fwebpack.js.org\u002F\" target=\"_blank\">WebPack\u003C\u002Fa>, or \u003Ca href=\"https:\u002F\u002Frollupjs.org\u002Fguide\u002Fen\" target=\"_blank\">Rollup\u003C\u002Fa>.\n\n### via Script Tag\n\nAdd the following code to an HTML file:\n\n```html\n\u003Chtml>\n  \u003Chead>\n    \u003C!-- Load TensorFlow.js -->\n    \u003Cscript src=\"https:\u002F\u002Fcdn.jsdelivr.net\u002Fnpm\u002F@tensorflow\u002Ftfjs\u002Fdist\u002Ftf.min.js\"> \u003C\u002Fscript>\n\n\n    \u003C!-- Place your code in the script tag below. You can also use an external .js file -->\n    \u003Cscript>\n      \u002F\u002F Notice there is no 'import' statement. 'tf' is available on the index-page\n      \u002F\u002F because of the script tag above.\n\n      \u002F\u002F Define a model for linear regression.\n      const model = tf.sequential();\n      model.add(tf.layers.dense({units: 1, inputShape: [1]}));\n\n      \u002F\u002F Prepare the model for training: Specify the loss and the optimizer.\n      model.compile({loss: 'meanSquaredError', optimizer: 'sgd'});\n\n      \u002F\u002F Generate some synthetic data for training.\n      const xs = tf.tensor2d([1, 2, 3, 4], [4, 1]);\n      const ys = tf.tensor2d([1, 3, 5, 7], [4, 1]);\n\n      \u002F\u002F Train the model using the data.\n      model.fit(xs, ys).then(() => {\n        \u002F\u002F Use the model to do inference on a data point the model hasn't seen before:\n        \u002F\u002F Open the browser devtools to see the output\n        model.predict(tf.tensor2d([5], [1, 1])).print();\n      });\n    \u003C\u002Fscript>\n  \u003C\u002Fhead>\n\n  \u003Cbody>\n  \u003C\u002Fbody>\n\u003C\u002Fhtml>\n```\n\nOpen up that HTML file in your browser, and the code should run!\n\n### via NPM\n\nAdd TensorFlow.js to your project using \u003Ca href=\"https:\u002F\u002Fyarnpkg.com\u002Fen\u002F\" target=\"_blank\">yarn\u003C\u002Fa> \u003Cem>or\u003C\u002Fem> \u003Ca href=\"https:\u002F\u002Fdocs.npmjs.com\u002Fcli\u002Fnpm\" target=\"_blank\">npm\u003C\u002Fa>. \u003Cb>Note:\u003C\u002Fb> Because\nwe use ES2017 syntax (such as `import`), this workflow assumes you are using a modern browser or a bundler\u002Ftranspiler\nto convert your code to something older browsers understand. See our\n\u003Ca href='https:\u002F\u002Fgithub.com\u002Ftensorflow\u002Ftfjs-examples' target=\"_blank\">examples\u003C\u002Fa>\nto see how we use \u003Ca href=\"https:\u002F\u002Fparceljs.org\u002F\" target=\"_blank\">Parcel\u003C\u002Fa> to build\nour code. However, you are free to use any build tool that you prefer.\n\n\n\n```js\nimport * as tf from '@tensorflow\u002Ftfjs';\n\n\u002F\u002F Define a model for linear regression.\nconst model = tf.sequential();\nmodel.add(tf.layers.dense({units: 1, inputShape: [1]}));\n\n\u002F\u002F Prepare the model for training: Specify the loss and the optimizer.\nmodel.compile({loss: 'meanSquaredError', optimizer: 'sgd'});\n\n\u002F\u002F Generate some synthetic data for training.\nconst xs = tf.tensor2d([1, 2, 3, 4], [4, 1]);\nconst ys = tf.tensor2d([1, 3, 5, 7], [4, 1]);\n\n\u002F\u002F Train the model using the data.\nmodel.fit(xs, ys).then(() => {\n  \u002F\u002F Use the model to do inference on a data point the model hasn't seen before:\n  model.predict(tf.tensor2d([5], [1, 1])).print();\n});\n```\n\nSee our \u003Ca href=\"https:\u002F\u002Fjs.tensorflow.org\u002Ftutorials\u002F\" target=\"_blank\">tutorials\u003C\u002Fa>, \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Ftensorflow\u002Ftfjs-examples\" target=\"_blank\">examples\u003C\u002Fa>\nand \u003Ca href=\"https:\u002F\u002Fjs.tensorflow.org\u002Fapi\u002Flatest\u002F\">documentation\u003C\u002Fa> for more details.\n\n## Importing pre-trained models\n\nWe support porting pre-trained models from:\n- [TensorFlow SavedModel](https:\u002F\u002Fwww.tensorflow.org\u002Fjs\u002Ftutorials\u002Fconversion\u002Fimport_saved_model)\n- [Keras](https:\u002F\u002Fjs.tensorflow.org\u002Ftutorials\u002Fimport-keras.html)\n\n## Various ops supported in different backends\n\nPlease refer below :\n- [TFJS Ops Matrix](https:\u002F\u002Fdocs.google.com\u002Fspreadsheets\u002Fd\u002F1D25XtWaBrmUEErbGQB0QmNhH-xtwHo9LDl59w0TbxrI\u002Fedit#gid=0)\n\n## Find out more\n\n[TensorFlow.js](https:\u002F\u002Fjs.tensorflow.org) is a part of the\n[TensorFlow](https:\u002F\u002Fwww.tensorflow.org) ecosystem. For more info:\n- For help from the community, use the `tfjs` tag on the [TensorFlow Forum](https:\u002F\u002Fdiscuss.tensorflow.org\u002Ftag\u002Ftfjs).\n- [TensorFlow.js Website](https:\u002F\u002Fjs.tensorflow.org)\n- [Tutorials](https:\u002F\u002Fjs.tensorflow.org\u002Ftutorials)\n- [API reference](https:\u002F\u002Fjs.tensorflow.org\u002Fapi\u002Flatest\u002F)\n- [TensorFlow.js Blog](https:\u002F\u002Fblog.tensorflow.org\u002Fsearch?label=TensorFlow.js)\n\nThanks, \u003Ca href=\"https:\u002F\u002Fwww.browserstack.com\u002F\">BrowserStack\u003C\u002Fa>, for providing testing support.\n","TensorFlow.js 是一个基于 WebGL 加速的 JavaScript 库，用于机器学习模型的训练和部署。它提供了灵活且直观的 API，支持从零开始构建模型或使用高级层 API 构建模型，并能够在浏览器或 Node.js 环境中运行现有的 TensorFlow 模型。此外，TensorFlow.js 支持通过传感器数据或其他客户端数据重新训练现有模型。该库包括多个后端（如 WebGL、WebAssembly 和 CPU）以适应不同场景下的性能需求，并提供了一系列工具包，如数据加载、模型转换及可视化等，使得开发者能够更高效地进行机器学习开发。适合需要在前端或轻量级环境中快速实现机器学习功能的应用场景。",2,"2026-06-11 02:56:03","top_language"]