{"id":14384654,"url":"https://github.com/tomasreimers/tensorjs","last_synced_at":"2025-04-30T15:47:56.014Z","repository":{"id":65515421,"uuid":"80877081","full_name":"tomasreimers/tensorjs","owner":"tomasreimers","description":"Read and write tensor protos from multidimensional arrays in Javascript.","archived":false,"fork":false,"pushed_at":"2017-02-25T20:51:23.000Z","size":20,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-30T15:47:46.320Z","etag":null,"topics":["javascript","tensor","tensorflow"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tomasreimers.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-03T23:06:18.000Z","updated_at":"2024-02-07T09:09:12.000Z","dependencies_parsed_at":"2023-01-26T21:25:11.674Z","dependency_job_id":null,"html_url":"https://github.com/tomasreimers/tensorjs","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/tomasreimers%2Ftensorjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomasreimers%2Ftensorjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomasreimers%2Ftensorjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomasreimers%2Ftensorjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tomasreimers","download_url":"https://codeload.github.com/tomasreimers/tensorjs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251734296,"owners_count":21635112,"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":["javascript","tensor","tensorflow"],"created_at":"2024-08-28T18:01:33.234Z","updated_at":"2025-04-30T15:47:55.947Z","avatar_url":"https://github.com/tomasreimers.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# Tensor JS\n\n## About\n\nThis library allows you to read and write Tensor protobufs (specifically the\ntensors that are used by the Google TensorFlow library). The tensors are encoded/decoded\nfrom multidimensional JS arrays.\n\n## Installation \u0026 Building\n\nTo install this:\n\n```\n$ npm install\n```\n\nIf you want to rebuild the protobuf implementations, feel free to recompile them\nby running (but there *should* be no reason to do this):\n\n```\n$ ./compile.sh\n```\n\n## Usage\n\n### Writing Tensor Protobufs\n\n#### Function Signature\n\n```\nmake_tensor(array, type)\n```\n\n - `array`: A multidimensional array representing the tensor you want to encode\n - `type`: One of lib.types.INT or lib.types.FLOAT representing which type of tensor it is\n - `RETURNS`: A string encoding the binary value of the tensor protobuf *(NOTE: There is some nonsense about encoding the strings as UINT8s but JS using utf-16. I think I've solved all the bugs, although it is possible there are still more.)*\n\n#### Example\n```\nconst tensorjs = require('tensorjs');\n\ntensorjs.make_tensor([[1, 2], [3, 4]], tensorjs.types.INT);\n// returns '\\b\\u0003\\u0012\\b\\u0012\\u0002\\b\\u0002\\u0012\\u0002\\b\\u0002:\\u0004\\u0001\\u0002\\u0003\\u0004'\n```\n\n#### Convenience Functions\n\nWe provide two convenience functions so that you don't have to pass in the type:\n\n```\ntensorjs.intTensor([[1, 2], [3, 4]]);\ntensorjs.floatTensor([1.5, 2.5]);\n```\n\n### Reading Tensor Protobufs\n\n#### Function Signature\n\n```\nmake_array(tensor_pb)\n```\n\n - `tensor_pb`: A string encoding the tensor protobuf.\n - `RETURNS`: A multidimensional array representing the tensor.\n\n#### Example\n```\nconst tensorjs = require('tensorjs');\n\ntensorjs.make_array('\\b\\u0003\\u0012\\b\\u0012\\u0002\\b\\u0002\\u0012\\u0002\\b\\u0002:\\u0004\\u0001\\u0002\\u0003\\u0004');\n// returns [[1, 2], [3, 4]]\n```\n\n## Author \u0026 License (MIT)\n\nCopyright (c) 2017 Tomas Reimers\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomasreimers%2Ftensorjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomasreimers%2Ftensorjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomasreimers%2Ftensorjs/lists"}