MLFairy

MLFairy

  • Docs
  • Blog
  • Sign In
  • Sign Up

›Recent Posts

Recent Posts

  • Genetic Algorithm in Swift
  • CoreML Drummer
  • LSTM with CoreML
  • Getting Started with Anaconda on Macs
  • Getting Started with Google Colab

Genetic Algorithm in Swift

March 15, 2020

Vijay Sharma

While researching and writing a completely different tutorial, I came across a really fun video by a YouTuber named Code Bullet. In the video, he shows viewers how to teach an A.I. agent to learn how to play Flappy Birds using a genetic algorithm named NeuroEvolution of Augmenting Topologies, or better known as NEAT. Now, I'd never heard of NEAT let alone genetic algorithm, but after watching the video, I was very curious about how it worked.

In this tutorial, you're going to work through a writing the code for a very basic genetic algorithm using Swift. The final project uses SwiftUI to help illustrate the point.

Read More

CoreML Drummer

February 15, 2020

Vijay Sharma

Generating media with deep learning is a dual-edge sword with both interesting and scary implications (e.g. deepfakes). However, one of the more uplifting domains is music generation. In this tutorial, you'll learn how to generate CoreML model that generates a rhythm sequence of MIDI notes.

Creating this kind of models doesn't fall under any of the task oriented models provided by either CreateML or TuriCreate, so you'll have to create and train the model using Keras, and then use a coremltools converter to convert the model into CoreML.

This tutorial was inspired by the Matthijs Hollemans' tutorial where he wrote an LSTM in Swift using the Accelerate framework. Its a very good tutorial, and many of the explanations won't be repeated here. Many tutorials have covered the topic of MIDI note generation before, however, one of the interesting approaches used by Matthijs in his tutorial is, he accounts for timing information during training.

Where Matthijs creates his model using tensorflow APIs, and implements his LSTM directly in Swift using the Accelerate framework, this tutorial will focus on creating a model using Keras, and then converting the model using coremltools.

In this tutorial, you'll learn how to

  • Create an LSTM model using Keras
  • Add a custom activation layer to the model
  • Use a custom loss function to train the model
  • Convert the model to CoreML
  • Write a Swift application to generate a rhythm.

This tutorial makes use Google Colab, however, feel free to use whatever development environment you wish. You can always look at the completed notebook here

Read More

LSTM with CoreML

January 31, 2020

Vijay Sharma

LSTTMs can be very effective when it comes to finding patterns in sequence-based data. In this tutorial, you'll take a shallow dive into using LSTMs with CoreML. The objective of this tutorial will be to look at how work with LSTMs in CoreML.

By the end of this tutorial, you'll learn how to

  • Create an LSTM model using Keras
  • Use coremltools to convert the Keras model to CoreML
  • Shape the input data for your CoreML model, and see the results in Swift
Read More

Getting Started with Anaconda on Macs

January 20, 2020

Vijay Sharma

The data science community developed Conda to make life with Python easier. Conda handles Python language versions, Python packages, and associated native libraries. It’s both an environment manager and a package manager. And, if you need a package that Conda doesn’t know about, you can use pip within a conda environment to grab the package.

This site will primarily use Python environments in its tutorial. Therefore having some basic instructions on how to configure your environment is important. In this tutorial, you'll learn how to:

  • Unstall Anaconda on your Mac
  • How to create an environment
  • How to manage your environment
Read More

Getting Started with Google Colab

January 15, 2020

Vijay Sharma

Google Research’s Colaboratory at colab.research.google.com is a Jupyter Notebook environment that runs in a browser. It comes with many of the machine learning libraries you’ll need, already installed. Its best feature is, you can set the runtime type of a notebook to GPU to use Google’s GPU for free. It even lets you use Google’s TPUs (tensor processing units).

In this tutorial, you'll go over how to get started with Google Colab. By the end of the tutorial, you should know how to:

  • Add Google Colab as an app to Google Drive
  • Set the runtime type to GPU
  • Access dataset files in your Google Drive
Read More
Docs | Privacy | Terms
Copyright © 2020 9594426 Canada Inc.