Swift-AI

2.0.0

The Swift machine learning library.
Swift-AI/Swift-AI

What's New

Swift 3.1

2017-04-05T00:55:20Z

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!

Swift AI Banner

Swift AI is a high-performance machine learning library written entirely in Swift. We currently support iOS and OS X, with support for more platforms coming soon!

Features

Swift AI includes a set of common tools used for machine learning and artificial intelligence research. These tools are designed to be flexible, powerful and suitable for a wide range of applications.

  • Feed-Forward Neural Network
    • 3-layer network with options for customization.
    • Example projects for iOS and OS X.
  • Recurrent Neural Network
  • Convolutional Network
  • GPU-Accelerated Networks
  • Genetic Algorithms
  • Fast Matrix Library
    • Matrix class supporting common operators
    • SIMD-accelerated operations
  • Fourier Transform Functions

What It's For

"This is a really cool project, but what can I actually do with it? I know nothing about A.I."

I get this question a lot, so I want to address it here:

Swift AI focuses on a useful branch of artificial intelligence known as machine learning: the science of training computers to take actions without explicit programming. Used appropriately, these tools can give your applications abilities that would normally be impossible or unrealistic using conventional programming techniques.

As an example, consider an app that recognizes handwritten letters on a piece of paper: using the computer science you learned in school, you might be tempted to write each of the rules for classifying each character individually. This would consist of extracting pixel data from the image, reading them in individually, and writing an extremely complicated mathematical model that relates pixel darkness/position into a probability for the letter A, and then likewise for B, C, D, etc. Sound fun? Here's what your program might eventually look like:

if /* massive function for checking the letter A */ {
    return "A"
} else if /* massive, completely unique function for checking the letter B */ { 
    return "B"
} else if ...

Hopefully you've realized by now that this method simply isn't feasible. In the best case scenario, you might end up with thousands of lines of very unreliable code for recognizing only your exact handwriting. In comparison, Swift AI's iOS example app demonstrates how far superior functionality can be accomplished with very few lines of code, using machine learning. And requiring exactly zero explicit rules to be written by the developer.

So how can Swift AI be used in the real world?

Here are a few ideas to get you started:

  • Handwriting recognition
  • Gesture recognition
  • Facial detection
  • Drone stabilization and navigation systems
  • Predicting and identifying medical conditions
  • Song identification (e.g., Shazam)
  • Speech recognition
  • Video game AI
  • Weather forecasting
  • Fraud detection
  • Building smart robots!

Usage and Examples

Please see the documentation for detailed instructions on how to use the various components of Swift AI.

We've also created example projects to demonstrate the usage and potential applications of this library:

  • iOS:
    • 2D function regression (feed-forward neural network)
    • Handwriting recognition (feed-forward neural network)
    • Evolution simulation (genetic algorithm)
  • OS X:
    • XOR logic gate modeling (feed-forward neural network)
    • 2D function regression (feed-forward neural network)
    • Trainer for iOS handwriting recognizer (feed-forward neural network)
  • Swift Playground:
    • Graphing - used in conjunction with OS X regression examples

Installation

Grab the files you need, drag them into your project. That was easy!

Why don't we use CocoaPods/Carthage?

Because we're migrating to the Swift Package Manager.

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 (Linux, Windows, etc.), alternative BLAS solutions are being considered. A vanilla Swift implementation is one possibility, but SIMD instructions will be preferred for their significant performance boost. Check back for more updates on this soon.

Using Swift AI?

If you're using Swift AI in one of your own projects, let me know! I'll add a link to your profile/website/app right here on the front page. Feel free to email me at the address shown below.

Contributing

Contributions to the project are welcome. Please review the documentation before submitting a pull request, and strive to maintain consistency with the structure and formatting of existing code. Official guidelines with more details will be provided soon.

Contact

I do all things Swift - from cloud technologies to iOS apps. You can reach me here:

Email

Become a Sponsor

Due to recent interest, we're now accepting corporate sponsorships. If your company is interested in becoming a sponsor, contact me at the address above.

Care Enough to Donate?

Everyone needs to eat, and our amazing supporters are what have made Swift AI possible.

Your donation will help continue the development of open-source machine learning technologies, benefitting millions of users worldwide!

Donate

Description

  • Swift Tools 3.1.0

Dependencies

  • None
Last updated: Fri Nov 27 2020 09:48:38 GMT-0500 (GMT-05:00)