Coder Social home page Coder Social logo

swift-apis's Introduction

Swift for TensorFlow APIs

Deep learning library for Swift for TensorFlow.

Requirements

  • A latest Swift for TensorFlow toolchain.

Usage

A Swift for TensorFlow toolchain is required to use this package. Add the following to your Swift package manifest.

packages: [
  .package(url: "https://github.com/tensorflow/swift-apis.git")
]

To get started, simply import TensorFlow in your Swift code.

import TensorFlow

// Define a model.
struct Classifier: Layer {
    var l1, l2: Dense<Float>

    func applied(to input: Tensor<Float>) -> Tensor<Float> {
        let h1 = sigmoid(l1.applied(to: input))
        return sigmoid(l2.applied(to: h1))
    }
}

var model = Classifier(...)
let optimizer = SGD<Classifier, Float>(learningRate: 0.02)
for _ in 0..<1000 {
    let (loss, 𝛁model) = model.valueWithGradient { model in
        let ŷ = model.applied(to: x)
        print("Prediction: \(ŷ)")
        return (y - ŷ).squared().mean()
    }
    print("Loss: \(loss)")
    optimizer.update(&model.allDifferentiableVariables,
                     along: 𝛁model)
}

Building

swift build

Bugs

Please report bugs and feature requests using GitHub issues in this repository.

Community

Discussion about Swift for TensorFlow happens on the [email protected] mailing list.

Contributing

We welcome contributions: please read the Contributor Guide to get started. It's always a good idea to discuss your plans on the mailing list before making any major submissions.

Code of Conduct

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.

The Swift for TensorFlow community is guided by our Code of Conduct, which we encourage everybody to read before participating.

swift-apis's People

Contributors

dan-zheng avatar rxwei avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.