What is the future for Machine learning/Deep learning with GoLang !
Published:
Machine Learning/Deep learning & GoLang? How does it work? or Do they have any future together? Golang VS Python?
Golang?
Go (or Golang) originates from Google, where its design began in 2007. Its stated objectives were to create an efficient, compiled programming language that feels lightweight and pleasant. Go benefits from a number of features that are designed to boost productivity and reliability of production applications.
GoLang with machine learning/Deep learning:
We all know python is one of the best scripting languae out there. The scripting language means it doesn’t need any compiler , rather it uses intrepreter. Interpreter works with machine to make it interpretable by converting to native machine code. Whereas other non scriting OOP languages need the compilation steps and that is the reason why non scripting languages are so faster than Python or scripting languages. In addition, compiler works with the code only one time but interpreted works with each statement it gets and check for the probable error. It helps to interpret the every line of code with the help of notebook like jupyter. People from every background including non-technical or STEM can learn and use python without having nay good prior knowledge of programming and mathematics.
The uses of Python and why?:
- Data exploration and extracting information
- Automating certain task with the help of various library
- Less code intensive with easy to learn syntax
- Tons of built in libraries for various fileds
- Ready made tools like scikit-learn for machine learning
- Wide used by industry and all data science or data engineering people.
- The powerful numpy which can speeds up the process 10 or more times faster.
- Versatility.
- Aamzing eastablished vast community support for machine learning and deep elarning.
GoLang with machine learning/Deep learning:
Go is one of the easy to use, clean and effecient high level language. Unlike python it is a compiler language which needs compiler to compile. Golang has very less support from machine learning community but there are some projects and libraries which are growing fast with the help of some amazing developers. There are many reason why we can use Golang and why there might be a good future with this track.
Why write ML applications in Go?
There are libraries for other languages, especially Python, that are more complete than Go ML libraries and have benefited from years, if not decades, of research from the worlds brightest brains. Some Go programmers make the transition to Go in search of better performance, but because ML libraries are typically written in C and exposed to Python through their bindings, they do not suffer the same performance problems as interpreted Python programs. Deep learning frameworks such as TensorFlow and Caffe have very limited, if any, bindings to Go. Even with these issues in mind, Go is still an excellent, if not the best, language to develop an application containing ML components. There are also more concrete reasons:
- Go is quite easy and fun to write. So organzied and cool to look.
- Compialton & Runtime is tremendously faster
- One of the best language for effecient parallelization unlike python which has huge bottleneck because of GIL(Global Interpreter Lock)
- New Type mechanism with the sfaety for static typing, huge flexibility of dynamic and interfaces.
- GoRoutine, channel and events made it more fun.
- Lot of libraries out there and there are lot of chnace to contrubte as it needs more support and contribution.
Go Libraries for Machine Learning:
Go Notebooks:
It is possible to use Go Notebook like Python Jupyter Notebook for data science or machine learning. There is a Jupyter kernel for Go which makes interactive environment to produce and share live code over various way like Dropbox and Github and the notebook format. It is possible to use with with all othe OS out there and it also has docker support.
Link: https://github.com/gopherdata/gophernotes
Gonum:
If you ask any data scientist or machine learning scientist what could be a most important libraries if you need to move from python to any other language? The answer should be numpy. Yes ! Numpy is one of the mot important libraries for Machine learning or Data science related work. Dan Kortschak come up with Gonum for Go. It is consists of set of numeric libraries for Go which incudes libraries for matrices, statistics, optimization and more. It is not mature like numpy but it is quite good. I have used by myself and i was able to replicate lot of stuffs which i have done with pythin numpy. It really cool to play with vecotr and matrix in Go, it is not the easiest one but it is not th worst one i must say. There are still few things you can not do with Gonum but it is growing stronger.
Some mathematical operations with Gonum:
- https://github.com/gonumhttps://github.com/gonum/unit: Package for converting between scientific units
- https://github.com/gonum/mathext: mathext implements basic elementary functions not included in the Go standard library
- https://github.com/gonum/matrix: Matrix packages for the Go language
- https://github.com/gonum/plot: A repository for plotting and visualizing data
- https://github.com/gonum/blas: Basic Linear Algebra Sub Programs Implementation
- https://github.com/gonum/graph: Graph packages for the Go language
- https://github.com/gonum/lapack: Linear Algebra Package
GoLearn:
This is one of the most interesting libraries out there for Machine learning with Go. With the help of this library it is possible to do different operation like readin and writing csv files, splitting the train and test datasets, implementing custion datagrid and so on. It is possible to contribute to this project to make it bigger and stable.
There are some machine learning algorithm availabel with golearn also.
- KNN Algorithms
- k-means, k-medians, k-medoids clustering
- Decision Trees
- Regression
- Filtering
- single-linkage hierarchical clustering
- SVC & MultiLinear SVC
- Gaussian mixture model clustering
- Gaussian Multivariate Distribution for anomaly detection systems
- More
Here is a simple exaplew with GoLearn. Code excerpt: loading a dataset and splitting it into training and test sets
// Load in the iris dataset
iris, _ := base.ParseCSVToInstances("../datasets/iris_headers.csv", true)
// Create a 60-40 training-test split
trainData, testData := base.InstancesTrainTestSplit(iris, 0.60)
To know more and contribute more , please visit the github page.
Link: https://github.com/sjwhitworth/golearn/wiki
GoML:
Algorithms that learning, used for implementation of learning on the wire, running algorithms while the data is in the streams, channels, very well tested, extensive documentation.
https://github.com/cdipaolo/goml:
Deep Learning with GO:
Sadly, Deep learning with Go still a difficult task to solve. There are not many native support for Deep Learning algorithms with Go. Sadly, Deep learning with Go still a difficult task to solve. There are not many native support for Deep Learning algorithms with Go. The good thing there are som libraries which are already developing and we can start from there. It is really better than having.
Gorgonia:
It is very similar implementation to theano, allows us to define behavior about neural networks at a high level, but much much easier to deploy on various interfaces than theano.
The primary goal for Gorgonia is to be a highly performant machine learning/graph computation-based library that can scale across multiple machines. It should bring the appeal of Go (simple compilation and deployment process) to the ML world. It’s a long way from there currently, however, the baby steps are already there.
The secondary goal for Gorgonia is to provide a platform for exploration for non-standard deep-learning and neural network related things. This includes things like neo-hebbian learning, corner-cutting algorithms, evolutionary algorithms and the like.
- Can perform automatic differentiation
- Can perform symbolic differentiation
- Can perform gradient descent optimizations
- Can perform numerical stabilization
- Provides a number of convenience functions to help create neural networks
- Is fairly quick (comparable to Theano and Tensorflow’s speed)
- Supports CUDA/GPGPU computation (OpenCL not yet supported, send a pull request)
- Will support distributed computing
Gorgonia: https://github.com/chewxy/gorgonia
Here’s an example - say you want to define a math expression z = x + y. Here’s how you’d do it:
package gorgonia_test
import (
"fmt"
"log"
. "gorgonia.org/gorgonia"
)
// Basic example of representing mathematical equations as graphs.
//
// In this example, we want to represent the following equation
// z = x + y
func Example_basic() {
g := NewGraph()
var x, y, z *Node
var err error
// define the expression
x = NewScalar(g, Float64, WithName("x"))
y = NewScalar(g, Float64, WithName("y"))
if z, err = Add(x, y); err != nil {
log.Fatal(err)
}
// create a VM to run the program on
machine := NewTapeMachine(g)
defer machine.Close()
// set initial values then run
Let(x, 2.0)
Let(y, 2.5)
if err = machine.RunAll(); err != nil {
log.Fatal(err)
}
fmt.Printf("%v", z.Value())
// Output: 4.5
}
Tensorflow Support:
TensorFlow is an open source software library for numerical computation using data flow graphs. Nodes in the graph represent mathematical operations, while the graph edges represent the multidimensional data arrays (tensors) communicated between them.
Caffe Support:
Caffe is a deep learning framework made with expression, speed, and modularity in mind. It is developed by the Berkeley Vision and Learning Center (BVLC)
https://github.com/wmyaoyao/gocaffe
To sum up, Go is much faster and for multiprocessing applications, it is going to be a blessed language always. Now a days, machine learning is using in a large scale and the necessity of having scalibity and concurrency is becoming more and more important. Python is by far the best choice for ML but we just can not throw aways Go. I belive there is a great futurw waiting with Go and ML.