The Swift machine learning library.

Overview

Banner

Swift AI is a high-performance deep learning library written entirely in Swift. We currently offer support for all Apple platforms, with Linux support coming soon.

Tools

Swift AI includes a collection of common tools used for artificial intelligence and scientific applications:

  • NeuralNet
    • A flexible, fully-connected neural network with support for deep learning
    • Optimized specifically for Apple hardware, using advanced parallel processing techniques
  • Convolutional Neural Network
  • Recurrent Neural Network
  • Genetic Algorithm Library
  • Fast Linear Algebra Library
  • Signal Processing Library

Example Projects

We've created some example projects to demonstrate the usage of Swift AI. Each resides in their own repository and can be built with little or no configuration:

Usage

Each module now contains its own documentation. We recommend that you read the docs carefully for detailed instructions on using the various components of Swift AI.

The example projects are another great resource for seeing real-world usage of these tools.

Compatibility

Swift AI currently depends on Apple's Accelerate framework for vector/matrix calculations and digital signal processing.

In order to provide support for more platforms, alternative BLAS solutions are being considered.

Contributing

Contributions to the project are welcome. We simply ask that you strive to maintain consistency with the structure and formatting of existing code.

Contact

Collin Hundley is the author and maintainer of Swift AI. Feel free contact him directly via email.

If you have a question about this library or are looking for guidance, we recommend opening an issue so a member of the community can help!

Consulting

If you're looking for for help with deep learning, computer vision, signal processing or other AI applications, you've come to the right place! Contact Collin for more information about consulting/contracting.

Donating

Your donation to Swift AI will help us continue building excellent open-source tools. All contributions are appreciated!

Donate

Comments
  • Recurrent Neural Network

    Recurrent Neural Network

    @KacheFlowe @joobei Hey guys, sorry for my apparent lack of communication over the last little while. New startup, crazy hours, no sleep... you know the routine! Definitely haven't left Swift AI behind though, and in fact it's finally made its way back up my priority list.

    It's been some time since we've discussed Recurrent Neural Networks - any progress or thoughts from you guys? I've decided that it's the next component I want to tackle, partly because it would be particularly useful for some side projects that I have in mind. I definitely don't want to duplicate any effort that people have already made, if any, so I'd love to hear what you guys think about the idea.

    opened by collinhundley 19
  • APKit

    APKit

    I get an error saying: Module file was created by an older version of the compiler; rebuild 'APKit' and try again

    when I try to run the iOS example project.

    opened by mrtnstolk 17
  • What needs work on?

    What needs work on?

    Hi. Since Github eliminated private messaging I find it difficult to comunicate with developers. I'm just wondering if there's a feature I can tackle or code I can take off yoru plate.

    opened by Jxrgxn 17
  • Recurrent Neural Network (RNN)

    Recurrent Neural Network (RNN)

    I am looking to implement an RNN in swift and I'm wondering if there's already some effort underway to add an RNN to Swift-AI. So that there is no duplication of effort. Is there some RNN effort by somebody?

    Thanks in advance.

    opened by joobei 11
  • Explanation

    Explanation

    Can someone explain me these lines: let x = (-500 + (Float(index) * 1000) / Float(self.numPoints)) / 100 try! self.network.update(inputs: [x]) let answer = self.sineFunc(x) print("\(x):\(answer)") try! self.network.backpropagate(answer: [answer]) I don't get where the AI calculates the points here.

    opened by telip007 9
  • Separate Storage

    Separate Storage

    I believe there was a discussion about it should be possible to use the framework just by dragging in a single file (currently FFNN.swift). Right now, FFNN conforming to Storage is preventing this from happening. What's the issue with moving this snippet into Storage.swift?

    opened by Danappelxx 7
  • Storage functionalities

    Storage functionalities

    Added Storage functionalities so we can load a NN from a file. I've not used the NSCoding protocol to avoid the @objc directive. ActivationFunction now is of type String, we could also use Int

    opened by angu 7
  • Re-think the storage, vDSP calls…

    Re-think the storage, vDSP calls…

    Someone pointed out this code base to me recently, and it's very cool stuff. While poking around I found things like this:

    https://github.com/collinhundley/Swift-AI/blob/master/Source/Vector.swift#L14

    While I also use a straight-up swift array to back my own publicly-available vectors at https://github.com/liscio/SMUGMath-Swift, I have recently found that it's not a great idea in practice—Arrays aren't necessarily guaranteed to be contiguous in memory. Instead I would recommend that you use ContiguousArray<Float> for the flat definition, and also surround your Accelerate accesses using withUnsafe{,Mutable}Pointer as I do in the code here:

    https://github.com/liscio/SMUGMath-Swift/blob/master/SMUGMath/RealVectorOperations.swift

    I don't yet have concrete plans to put my new code into the repo above because it is still in progress and tightly coupled with something else I'm working on.

    Anyway—really cool repo, and subject matter!

    opened by liscio 5
  • Support for deep FFNNs

    Support for deep FFNNs

    Hi! I've developed a similar library, except focused on customization instead of performance. The only feature I miss from my implementation is the ability to specify an arbitrary number of hidden layers, and it would be nice to see it in Swift-AI.

    The way I implemented it, the designated initializer would take an [Int] for the hidden parameter, each Int being the size of that hidden layer. The rest of the interface stays pretty much the same.

    P.s. why are all member accesses qualified with self.? This is Swift man :)

    opened by mipstian 5
  • Where is actually the code?

    Where is actually the code?

    "Swift AI is a high-performance deep learning library " --> but where is the code? Is it this only library https://github.com/Swift-AI/NeuralNet ?

    opened by kokinarido 4
  • Cannot compile under new Swift 3 (need for latest iOS)

    Cannot compile under new Swift 3 (need for latest iOS)

    I accept conversion (no choice) but then 2 error messages: 1.

    public func toString(decimalPlaces: Int) -> String {
        let power = pow(10.0, Double(decimalPlaces))
        return "\(round(power * self) / power)"
    }
    

    --> cannot use mutating member on immutable value "self" is immutable ...

    and

    let providerRef = CGDataProvider(data: Data(bytes: UnsafePointer(&data), count: data.count * sizeof(PixelData)))

    --> ambiguous use of 'init'

    opened by kwccoin 4
  • Image classification

    Image classification

    Hi Team,

    Is it possible to classify the images using this library? like categories the images or detecting the object in image?

    Need assistance on this.

    opened by sandeepkumarrepo 0
  • Need to apply Mfcc and Spectrogram to the audio file

    Need to apply Mfcc and Spectrogram to the audio file

    Hello, I am creating the iOS Mobile application to detect snoring, I need to apply Mfcc and Spectrogram to the audio file and need to pass these two in the Tensorflow lite I need to apply Mfcc [Mel-frequency cepstral coefficients] and Spectrogram to the audio file. Can you suggest me any solution for this?

    Thanks in Advance!

    opened by AlexJones0412 1
  • Neural Networks for Regression are not possible

    Neural Networks for Regression are not possible

    Tried to use a simple Neural Network without an activation layer at the output. The output needs to be a continuous number (example price). The API requires an activation function (linear), but the back-propagation is not implemented.

    opened by borozanov 0
  • Genetic Algorithm

    Genetic Algorithm

    This probably isn't an issue for this SDK, I just added this as a "discussion"...

    I've been messing around with getting Neural Networks to play games, for example, but I want to take it a step further: Would it be possible to use something like "Mendel" (an iOS SDK for Genetic Algorithms) to evolve a Neural Network using this SDK?

    • Tanmay Bakshi (TajyMany)
    feature 
    opened by tanmayb123 3
Releases(2.0.0)
  • 2.0.0(Apr 5, 2017)

    Swift AI has been completely rewritten for Swift 3.1!

    This update brings many changes, so I'd like to note a few of the biggest ones here:

    • Swift 3.1 language support
    • Swift Package Manager support
    • Significant API improvements and syntactical changes
    • Support for custom activation functions and cost functions!
    • Persistent storage now uses plaintext JSON for easy readability and cross-platform support
    • FFNN has been renamed to NeuralNet
    • Various performance improvements

    We've also removed some components from this repository. Namely:

    • Example projects
    • Vector/matrix library
    • Random number generator

    The reason for removing these components is simple: in accordance with its SPM support, Swift AI is intended to be modular and expandable. Importing a neural network should not require you to import an entire collection of documentation and iOS example projects ;)

    This is just Phase 1 of a series of changes that are planned for Swift AI. For the time being, the NeuralNet module will remain here in the top-level repository - but the ultimate goal is to create a GitHub organization account and continue expanding the library with new tools in their own individual packages.

    Thank you for all your support and contributions!

    Source code(tar.gz)
    Source code(zip)
  • 1.0.0(Nov 30, 2016)

    v1.0 is the official Swift 2.2 release of Swift AI. This release is pre-Swift Package Manager and includes the example projects bundled in the main repo.

    All future versions will be built for Swift 3 with SPM support.

    Source code(tar.gz)
    Source code(zip)
Owner
Swift AI
The Swift machine learning library
Swift AI
MLKit is a simple machine learning framework written in Swift.

MLKit (a.k.a Machine Learning Kit) ?? MLKit is a simple machine learning framework written in Swift. Currently MLKit features machine learning algorit

Guled 152 Nov 17, 2022
Artificial intelligence/machine learning data structures and Swift algorithms for future iOS development. bayes theorem, neural networks, and more AI.

Swift Brain The first neural network / machine learning library written in Swift. This is a project for AI algorithms in Swift for iOS and OS X develo

Vishal 331 Oct 14, 2022
Generate sniglets with machine learning

Give Me A Sniglet! Give Me a Sniglet is a random word-like generator with an on-device machine learning model that validates whether the word is likel

Marquis Kurt 4 Mar 3, 2022
🤗 Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.

English | 简体中文 | 繁體中文 | 한국어 State-of-the-art Machine Learning for JAX, PyTorch and TensorFlow ?? Transformers provides thousands of pretrained models

Hugging Face 77.1k Dec 31, 2022
Mobile-ios-ml - SBB Mobile Machine Learning for iOS devices

ESTA library: Machine Learning for iOS This framework simplifies the integration

Swiss Federal Railways (SBB) 9 Jul 16, 2022
A Swift deep learning library with Accelerate and Metal support.

Serrano Aiming to offering popular and cutting edge techs in deep learning area on iOS devices, Serrano is developed as a tool for developers & resear

pcpLiu 51 Nov 17, 2022
A simple deep learning library for estimating a set of tags and extracting semantic feature vectors from given illustrations.

Illustration2Vec illustration2vec (i2v) is a simple library for estimating a set of tags and extracting semantic feature vectors from given illustrati

Masaki Saito 661 Dec 12, 2022
British Machine Vision Conference (BMVC)

Introduction This repository contains the model files, solver definitions, and learned weights for the networks described in the following publication

Scott Workman 34 Sep 6, 2022
This repo contains beginner examples to advanced in swift. Aim to create this for learning native iOS development.

iOS-learning-with-swift-22 This repo contains beginner examples to advanced in swift. Aim to create this for learning native iOS development. Oh, you

Umesh Jangid 0 Jan 9, 2022
Scutil - The swift version of my ASOC scutilUtil application. An interesting learning excercise

scutil this is the swift version of my ASOC "scutilUtil" application. An interes

null 1 Feb 15, 2022
On-device wake word detection powered by deep learning.

Porcupine Made in Vancouver, Canada by Picovoice Porcupine is a highly-accurate and lightweight wake word engine. It enables building always-listening

Picovoice 2.8k Dec 30, 2022
DL4S provides a high-level API for many accelerated operations common in neural networks and deep learning.

DL4S provides a high-level API for many accelerated operations common in neural networks and deep learning. It furthermore has automatic differentiati

DL4S Team 2 Dec 5, 2021
Automatic spoken language identification (LID) using deep learning.

iLID Automatic spoken language identification (LID) using deep learning. Motivation We wanted to classify the spoken language within audio files, a pr

Thomas Werkmeister 85 Apr 3, 2022
This is an open-source project for the aesthetic evaluation of images based on the deep learning-caffe framework, which we completed in the Victory team of Besti.

This is an open-source project for the aesthetic evaluation of images based on the deep learning-caffe framework, which we completed in the Victory team of Besti.

The Victory Group of Besti 102 Dec 15, 2022
Conjugar is an app for learning Spanish verb conjugations.

Introduction Conjugar is an iPhone™ app for learning Spanish verb conjugations. Conjugar conjugates most Spanish verbs, regular and irregular, in all

Josh Adams 34 Oct 5, 2022
A Swift library for creating and exporting CoreML Models in Swift

SwiftCoreMLTools A Swift Library for creating CoreML models in Swift. Work in progress This library expose a (function builder based) DSL as well as a

Jacopo Mangiavacchi 140 Dec 5, 2022
Matft is Numpy-like library in Swift. Function name and usage is similar to Numpy.

Numpy-like library in swift. (Multi-dimensional Array, ndarray, matrix and vector library)

null 80 Dec 21, 2022
A lightweight library to calculate tensors in Swift, which has similar APIs to TensorFlow's

TensorSwift TensorSwift is a lightweight library to calculate tensors, which has similar APIs to TensorFlow's. TensorSwift is useful to simulate calcu

Qoncept, Inc. 323 Oct 20, 2022
Accelerated tensor operations and dynamic neural networks based on reverse mode automatic differentiation for every device that can run Swift - from watchOS to Linux

DL4S provides a high-level API for many accelerated operations common in neural networks and deep learning. It furthermore has automatic differentiati

Palle 87 Dec 29, 2022