{"id":28631119,"url":"https://github.com/zaccharieramzi/tf-slice-assign","last_synced_at":"2025-06-12T13:10:17.367Z","repository":{"id":48478046,"uuid":"268524038","full_name":"zaccharieramzi/tf-slice-assign","owner":"zaccharieramzi","description":"A tool for assignment to a slice in TensorFlow","archived":false,"fork":false,"pushed_at":"2021-07-23T16:30:06.000Z","size":25,"stargazers_count":20,"open_issues_count":3,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-04T11:55:59.823Z","etag":null,"topics":["tensorflow"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zaccharieramzi.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}},"created_at":"2020-06-01T13:04:43.000Z","updated_at":"2025-03-10T10:02:09.000Z","dependencies_parsed_at":"2022-08-27T19:12:36.394Z","dependency_job_id":null,"html_url":"https://github.com/zaccharieramzi/tf-slice-assign","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/zaccharieramzi/tf-slice-assign","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaccharieramzi%2Ftf-slice-assign","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaccharieramzi%2Ftf-slice-assign/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaccharieramzi%2Ftf-slice-assign/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaccharieramzi%2Ftf-slice-assign/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zaccharieramzi","download_url":"https://codeload.github.com/zaccharieramzi/tf-slice-assign/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaccharieramzi%2Ftf-slice-assign/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259470953,"owners_count":22862999,"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":["tensorflow"],"created_at":"2025-06-12T13:10:15.513Z","updated_at":"2025-06-12T13:10:17.343Z","avatar_url":"https://github.com/zaccharieramzi.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tf-slice-assign\n\n![GitHub Workflow Build Status](https://github.com/zaccharieramzi/tf-slice-assign/workflows/Continuous%20testing/badge.svg)\n\nA tool for assignment to a slice in TensorFlow.\n\nIn TensorFlow, as opposed to Pytorch, it is currently impossible to assign to\nthe slice of a tensor in a range of different settings.\nTo mitigate this issue, `tf-slice-assign` introduces a single function that\nallows to do exactly this using [`tensor_scatter_nd_update`](https://www.tensorflow.org/api_docs/python/tf/tensor_scatter_nd_update).\n\n## Use\n\n```python\nfrom tf_slice_assign import slice_assign\n\nnew_tensor = slice_assign(old_tensor, assignment, *slice_args)\n```\n\nYou can find a relatively simple example [here](example.py).\n\n## Installation\n\n```\npip install tf-slice-assign\n```\n\n## List of GitHub issues and StackOverflow questions regarding TensorFlow slice assignment\nIn the following table, I am trying to give the reasons as to why no mitigation\nfor the current problem exists.\n\n| Link                                                                                                              | Status                                                                                                                             |\n|-------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------|\n| [SO](https://stackoverflow.com/questions/62092147/how-to-efficiently-assign-to-a-slice-of-a-tensor-in-tensorflow) | Current answer requires creating a `tf.Variable` for each slice assignment you make                                                                                            |\n| [GH](https://github.com/tensorflow/tensorflow/issues/36559#issue-561880519)                                       | Question is about `tf.Variable`                                                                                                    |\n| [SO](https://stackoverflow.com/questions/39157723/how-to-do-slice-assignment-in-tensorflow)                       | Answers for `tf.Variable` or using `tensor_scatter_update` in a non-adaptable way                                                  |\n| [GH](https://github.com/tensorflow/tensorflow/issues/33131#issue-503809713)                                       | Suggestion to use `tensor_scatter_nd_update`                                                                                       |\n| [GH](https://github.com/tensorflow/tensorflow/issues/14132#issue-270037738)                                       | An answer suggest creating a mask, but a mask can actually be as difficult to create as the indices for `tensor_scatter_nd_update` |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzaccharieramzi%2Ftf-slice-assign","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzaccharieramzi%2Ftf-slice-assign","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzaccharieramzi%2Ftf-slice-assign/lists"}