Implementing layers in Swift
There are at least three options to consider when you want to implement a NN in Swift:
- Implement it in pure Swift (which may be useful mostly for the study purposes). A lot of implementations of different complexity and functionality can be found on the GitHub. It looks like every programmer at some stage of her/his life starts to write a NN library in her/his favourite programming language.
- Implement it using low-level acceleration libraries—Metal Performance Shaders, or BNNS.
- Implement it using some general-purpose NN framework—Keras, TensorFlow, PyTorch, and so on—and then convert it to Core ML format.
Note
The Metal Performance Shader library includes three types of activations for NNs: ReLU, sigmoid, and TanH (MPSCNNNeuronReLU
, MPSCNNNeuronSigmoid
, MPSCNNNeuronTanH
). For more information refer to: https://developer.apple.com/reference/metalperformanceshaders.