{"id":13903082,"url":"https://github.com/tensorflow/swift-apis","last_synced_at":"2025-09-30T09:30:26.106Z","repository":{"id":34125955,"uuid":"170224648","full_name":"tensorflow/swift-apis","owner":"tensorflow","description":"Swift for TensorFlow Deep Learning Library","archived":true,"fork":false,"pushed_at":"2022-06-18T21:05:42.000Z","size":23898,"stargazers_count":793,"open_issues_count":63,"forks_count":138,"subscribers_count":42,"default_branch":"main","last_synced_at":"2025-09-25T00:31:11.820Z","etag":null,"topics":["deep-learning","differentiable-programming","swift","tensorflow"],"latest_commit_sha":null,"homepage":"","language":"Swift","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/tensorflow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-12T00:25:51.000Z","updated_at":"2025-08-27T12:19:17.000Z","dependencies_parsed_at":"2022-08-28T23:03:24.983Z","dependency_job_id":null,"html_url":"https://github.com/tensorflow/swift-apis","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/tensorflow/swift-apis","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tensorflow%2Fswift-apis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tensorflow%2Fswift-apis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tensorflow%2Fswift-apis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tensorflow%2Fswift-apis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tensorflow","download_url":"https://codeload.github.com/tensorflow/swift-apis/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tensorflow%2Fswift-apis/sbom","scorecard":{"id":873968,"data":{"date":"2025-08-11","repo":{"name":"github.com/tensorflow/swift-apis","commit":"f51ee4618d652a2419e998bf9418ad80bda67454"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.8,"checks":[{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":10,"reason":"all changesets reviewed","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"project is archived","details":["Warn: Repository is archived."],"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/macOS.yml:1","Warn: no topLevel permission defined: .github/workflows/windows.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/macOS.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/tensorflow/swift-apis/macOS.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/windows.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/tensorflow/swift-apis/windows.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/windows.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/tensorflow/swift-apis/windows.yml/main?enable=pin","Warn: containerImage not pinned by hash: Dockerfile:1: pin your Docker image by updating gcr.io/swift-tensorflow/base-deps-cuda10.2-cudnn7-ubuntu18.04 to gcr.io/swift-tensorflow/base-deps-cuda10.2-cudnn7-ubuntu18.04@sha256:a997e0c3fd367a06cfd32e446f833d8f02db1558d7f572f9365985c54f361281","Warn: pipCommand not pinned by hash: Dockerfile:45-46","Warn: pipCommand not pinned by hash: Dockerfile:45-46","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned","Info:   0 out of   1 containerImage dependencies pinned","Info:   0 out of   2 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-24T05:14:35.108Z","repository_id":34125955,"created_at":"2025-08-24T05:14:35.108Z","updated_at":"2025-08-24T05:14:35.108Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277665391,"owners_count":25856477,"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","status":"online","status_checked_at":"2025-09-30T02:00:09.208Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["deep-learning","differentiable-programming","swift","tensorflow"],"created_at":"2024-08-06T22:01:36.529Z","updated_at":"2025-09-30T09:30:25.586Z","avatar_url":"https://github.com/tensorflow.png","language":"Swift","funding_links":[],"categories":["Swift"],"sub_categories":[],"readme":"# Swift for TensorFlow Deep Learning Library\n\nGet a taste of *protocol-oriented differentiable programming*.\n\nThis repository hosts [Swift for TensorFlow][s4tf]'s deep learning library,\navailable both as a part of Swift for TensorFlow toolchains and as a Swift\npackage.\n\n## Usage\n\nThis library is being [automatically integrated][integrated] in Swift for\nTensorFlow toolchains. You do not need to add this library as a Swift Package\nManager dependency.\n\n### Use Google Colaboratory\n\n[**Open an empty Colaboratory now**][blank_colab] to try out Swift,\nTensorFlow, differentiable programming, and deep learning.\n\n\u003e For detailed usage and troubleshooting, see [Usage][usage] on the Swift for\nTensorFlow project homepage.\n\n#### Define a model\n\nSimply import `TensorFlow` to get the full power of TensorFlow.\n\n```swift\nimport TensorFlow\n\nlet hiddenSize: Int = 10\n\nstruct Model: Layer {\n    var layer1 = Dense\u003cFloat\u003e(inputSize: 4, outputSize: hiddenSize, activation: relu)\n    var layer2 = Dense\u003cFloat\u003e(inputSize: hiddenSize, outputSize: hiddenSize, activation: relu)\n    var layer3 = Dense\u003cFloat\u003e(inputSize: hiddenSize, outputSize: 3, activation: identity)\n    \n    @differentiable\n    func callAsFunction(_ input: Tensor\u003cFloat\u003e) -\u003e Tensor\u003cFloat\u003e {\n        return input.sequenced(through: layer1, layer2, layer3)\n    }\n}\n```\n\n#### Initialize a model and an optimizer\n\n```swift\nvar classifier = Model()\nlet optimizer = SGD(for: classifier, learningRate: 0.02)\nContext.local.learningPhase = .training\n// Dummy data.\nlet x: Tensor\u003cFloat\u003e = Tensor(randomNormal: [100, 4])\nlet y: Tensor\u003cInt32\u003e = Tensor(randomUniform: [100])\n```\n\n#### Run a training loop\n\nOne way to define a training epoch is to use the\n[`gradient(at:in:)`][gradient] function.\n\n```swift\nfor _ in 0..\u003c1000 {\n    let 𝛁model = gradient(at: classifier) { classifier -\u003e Tensor\u003cFloat\u003e in\n        let ŷ = classifier(x)\n        let loss = softmaxCrossEntropy(logits: ŷ, labels: y)\n        print(\"Loss: \\(loss)\")\n        return loss\n    }\n    optimizer.update(\u0026classifier, along: 𝛁model)\n}\n```\n\nAnother way is to make use of methods on `Differentiable` or `Layer` that\nproduce a backpropagation function. This allows you to compose your derivative\ncomputation with great flexibility.\n\n```swift\nfor _ in 0..\u003c1000 {\n    let (ŷ, backprop) = classifier.appliedForBackpropagation(to: x)\n    let (loss, 𝛁ŷ) = valueWithGradient(at: ŷ) { ŷ in softmaxCrossEntropy(logits: ŷ, labels: y) }\n    print(\"Model output: \\(ŷ), Loss: \\(loss)\")\n    let (𝛁model, _) = backprop(𝛁ŷ)\n    optimizer.update(\u0026classifier, along: 𝛁model)\n}\n```\n\nFor more models, go to [**tensorflow/swift-models**][swift-models].\n\n## Development\n\nDocumentation covering development can be found in the [Developer Guide](Documentation/Development.md).\n\n## Bugs\n\nPlease report bugs and feature requests using GitHub issues in this repository.\n\n## Community\n\nDiscussion about Swift for TensorFlow happens on the\n[swift@tensorflow.org][forum]\nmailing list.\n\n## Contributing\n\nWe welcome contributions: please read the [Contributor Guide](CONTRIBUTING.md)\nto get started. It's always a good idea to discuss your plans on the mailing\nlist before making any major submissions.\n\n## Code of Conduct\n\nIn the interest of fostering an open and welcoming environment, we as\ncontributors and maintainers pledge to making participation in our project and\nour community a harassment-free experience for everyone, regardless of age, body\nsize, disability, ethnicity, gender identity and expression, level of\nexperience, education, socio-economic status, nationality, personal appearance,\nrace, religion, or sexual identity and orientation.\n\nThe Swift for TensorFlow community is guided by our [Code of\nConduct](CODE_OF_CONDUCT.md), which we encourage everybody to read before\nparticipating.\n\n[s4tf]: https://github.com/tensorflow/swift\n[integrated]: https://github.com/apple/swift/tree/tensorflow#customize-tensorflow-support\n[blank_colab]: https://colab.research.google.com/notebook#create=true\u0026language=swift\n[usage]: https://github.com/tensorflow/swift/blob/main/Usage.md\n[gradient]: https://www.tensorflow.org/swift/api_docs/Functions#/s:10TensorFlow8gradient2at2in13TangentVectorQzx_AA0A0Vyq_GxXEtAA14DifferentiableRzAA0aB13FloatingPointR_r0_lF\n[swift-models]: https://github.com/tensorflow/swift-models\n[toolchain]: https://github.com/tensorflow/swift/blob/main/Installation.md\n[forum]: https://groups.google.com/a/tensorflow.org/d/forum/swift\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftensorflow%2Fswift-apis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftensorflow%2Fswift-apis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftensorflow%2Fswift-apis/lists"}