A High-level Machine Learning Library for Go

Overview

logo
GoDoc Go Report Card

Overview

Goro is a high-level machine learning library for Go built on Gorgonia. It aims to have the same feel as Keras.

Usage

import (
    . "github.com/aunum/goro/pkg/v1/model"
    "github.com/aunum/goro/pkg/v1/layer"
)

// create the 'x' input e.g. mnist image
x := NewInput("x", []int{1, 28, 28})

// create the 'y' or expect output e.g. labels
y := NewInput("y", []int{10})

// create a new sequential model with the name 'mnist'
model, _ := NewSequential("mnist")

// add layers to the model
model.AddLayers(
    layer.Conv2D{Input: 1, Output: 32, Width: 3, Height: 3},
    layer.MaxPooling2D{},
    layer.Conv2D{Input: 32, Output: 64, Width: 3, Height: 3},
    layer.MaxPooling2D{},
    layer.Conv2D{Input: 64, Output: 128, Width: 3, Height: 3},
    layer.MaxPooling2D{},
    layer.Flatten{},
    layer.FC{Input: 128 * 3 * 3, Output: 100},
    layer.FC{Input: 100, Output: 10, Activation: layer.Softmax},
)

// pick an optimizer
optimizer := g.NewRMSPropSolver()

// compile the model with options
model.Compile(xi, yi,
    WithOptimizer(optimizer),
    WithLoss(m.CrossEntropy),
    WithBatchSize(100),
)

// fit the model
model.Fit(xTrain, yTrain)

// use the model to predict an 'x'
prediction, _ := model.Predict(xTest)

// fit the model with a batch
model.FitBatch(xTrainBatch, yTrainBatch)

// use the model to predict a batch of 'x'
prediction, _ = model.PredictBatch(xTestBatch)

Examples

See the examples folder for example implementations.

There are many examples in the reinforcement learning library Gold.

Docs

Each package contains a README explaining the usage, also see GoDoc.

Contributing

Please open an MR for any issues or feature requests.

Feel free to ping @pbarker on Gopher slack.

Roadmap

  • RNN
  • LSTM
  • Summary
  • Visualization
Issues
  • Type Error

    Type Error

    Hi, I am new to using goro and cnns in general so right now I am trying to run the example mnist go file. However, I am running into the following error with WithOptimizer:

    cannot use optimizer (variable of type *gorgonia.RMSPropSolver) as gorgonia.Solver value in argument to m.WithOptimizer: wrong type for method Step (have func(model []gorgonia.org/gorgonia.ValueGrad) (err error), want func([]gorgonia.org/gorgonia.ValueGrad) error)compilerInvalidIfaceAssign

    I haven't changed anything in the example main.go file and I can import the following with no errors:

    import (
    	"github.com/aunum/gold/pkg/v1/common/num"
    	"github.com/aunum/gold/pkg/v1/common/require"
    	"github.com/aunum/gold/pkg/v1/dense"
    	"github.com/aunum/goro/pkg/v1/layer"
    	m "github.com/aunum/goro/pkg/v1/model"
    	"github.com/aunum/log"
    
    	g "gorgonia.org/gorgonia"
    	"gorgonia.org/gorgonia/examples/mnist"
    	"gorgonia.org/tensor"
    )
    

    I am just confused as to why WithOptimizer is not working for me. Thanks!

    opened by emmawuuu 1
  • Using `Init: gorgonia.Zeroes()` in every layer does not make output always zero

    Using `Init: gorgonia.Zeroes()` in every layer does not make output always zero

    Initializing network with the following code:

    qModel, err := m.NewSequential("qLearning")
    if err != nil {
    	return nil, err
    }
    
    xShape := []int{1, 71}
    yShape := []int{1, 16}
    in := m.NewInput("state", xShape)
    out := m.NewInput("actionValue", yShape)
    
    qModel.AddLayers(
    	layer.FC{Input: in.Squeeze()[0], Output: 256, Init: gorgonia.Zeroes()},
    	layer.FC{Input: 256, Output: 128, Init: gorgonia.Zeroes()},
    	layer.FC{Input: 128, Output: 64, Init: gorgonia.Zeroes()},
    	layer.FC{Input: 64, Output: 32, Init: gorgonia.Zeroes()},
    	layer.FC{Input: 32, Output: out.Squeeze()[0], Activation: layer.Linear, Init: gorgonia.Zeroes()},
    )
    
    err = qModel.Compile(in, out,
    	m.WithBatchSize(1),
    )
    if err != nil {
    	return nil, err
    }
    

    I want the initial output of the network to be zero for any input. What am I doing wrong?

    opened by bandreghetti 1
  • Create SetLearnables

    Create SetLearnables

    SetLearnables is a slight tweak on CloneLearnablesTo. It receives desired learnables of type gorgonia.Nodes and sets them in the present sequantial model.

    opened by samuelvenzi 0
Owner
AUNUM
AUNUM
Gorgonia is a library that helps facilitate machine learning in Go.

Gorgonia is a library that helps facilitate machine learning in Go. Write and evaluate mathematical equations involving multidimensional arrays easily

Gorgonia 4.5k May 16, 2022
Self-contained Machine Learning and Natural Language Processing library in Go

Self-contained Machine Learning and Natural Language Processing library in Go

NLP Odyssey 1.1k May 13, 2022
Machine Learning for Go

GoLearn GoLearn is a 'batteries included' machine learning library for Go. Simplicity, paired with customisability, is the goal. We are in active deve

Stephen Whitworth 8.3k May 15, 2022
On-line Machine Learning in Go (and so much more)

goml Golang Machine Learning, On The Wire goml is a machine learning library written entirely in Golang which lets the average developer include machi

Conner DiPaolo 1.3k May 19, 2022
Machine Learning libraries for Go Lang - Linear regression, Logistic regression, etc.

package ml - Machine Learning Libraries ###import "github.com/alonsovidales/go_ml" Package ml provides some implementations of usefull machine learnin

Alonso Vidales 194 Apr 22, 2022
Prophecis is a one-stop machine learning platform developed by WeBank

Prophecis is a one-stop machine learning platform developed by WeBank. It integrates multiple open-source machine learning frameworks, has the multi tenant management capability of machine learning compute cluster, and provides full stack container deployment and management services for production environment.

WeBankFinTech 331 May 9, 2022
Go Machine Learning Benchmarks

Benchmarks of machine learning inference for Go

Nikolay Dubina 22 May 7, 2022
Deploy, manage, and scale machine learning models in production

Deploy, manage, and scale machine learning models in production. Cortex is a cloud native model serving platform for machine learning engineering teams.

Cortex Labs 7.8k May 20, 2022
Standard machine learning models

Cog: Standard machine learning models Define your models in a standard format, store them in a central place, run them anywhere. Standard interface fo

Replicate 2.4k May 20, 2022
Katib is a Kubernetes-native project for automated machine learning (AutoML).

Katib is a Kubernetes-native project for automated machine learning (AutoML). Katib supports Hyperparameter Tuning, Early Stopping and Neural Architec

Kubeflow 1.2k May 11, 2022
PaddleDTX is a solution that focused on distributed machine learning technology based on decentralized storage.

中文 | English PaddleDTX PaddleDTX is a solution that focused on distributed machine learning technology based on decentralized storage. It solves the d

null 55 Apr 19, 2022
Go (Golang) encrypted deep learning library; Fully homomorphic encryption over neural network graphs

DC DarkLantern A lantern is a portable case that protects light, A dark lantern is one who's light can be hidden at will. DC DarkLantern is a golang i

Raven 1 Dec 2, 2021
Training materials and labs for a "Getting Started" level course on COBOL

COBOL Programming Course This project is a set of training materials and labs for COBOL on z/OS. The following books are available within this reposit

Open Mainframe Project 2.2k May 17, 2022
Reinforcement Learning in Go

Overview Gold is a reinforcement learning library for Go. It provides a set of agents that can be used to solve challenges in various environments. Th

AUNUM 269 May 20, 2022
Spice.ai is an open source, portable runtime for training and using deep learning on time series data.

Spice.ai Spice.ai is an open source, portable runtime for training and using deep learning on time series data. ⚠️ DEVELOPER PREVIEW ONLY Spice.ai is

Spice.ai 722 May 10, 2022
FlyML perfomant real time mashine learning libraryes in Go

FlyML perfomant real time mashine learning libraryes in Go simple & perfomant logistic regression (~100 LoC) Status: WIP! Validated on mushrooms datas

Vadim Kulibaba 0 May 3, 2022
A tool for building identical machine images for multiple platforms from a single source configuration

Packer Packer is a tool for building identical machine images for multiple platforms from a single source configuration. Packer is lightweight, runs o

null 2 Oct 3, 2021
A high performance go implementation of Wappalyzer Technology Detection Library

wappalyzergo A high performance port of the Wappalyzer Technology Detection Library to Go. Inspired by https://github.com/rverton/webanalyze. Features

ProjectDiscovery 246 May 12, 2022
A high-performance timeline tracing library for Golang, used by TiDB

Minitrace-Go A high-performance, ergonomic timeline tracing library for Golang. Basic Usage package main import ( "context" "fmt" "strcon

TiKV Project 43 May 5, 2022