Goro: 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
You might also like...
Skill builders for learning conversational Golang.

goPracticum Skill builders for learning conversational Golang. The Theory I'm stealing...err...borrowing profusely from human language learning and cu

CI/CD Learning

cicd-learning CI/CD Learning /gowebapp Building Here we will cover building the application and docker image Go To build the web app, just run, from t

Collecting and learning common algorithms

中文 Alogrithms Learning alogrithms. Dynamic Programming Fibonacci Grid Traveler Can Sum How Sum TODO Sorting Selection Sort Bubble Sort Insertion Sort

Golang - A collection of small Go programs used as learning exercises

This repo is a collection of small Go programs used as learning exercises Some o

This is a learning poem for golang~
This is a learning poem for golang~

golang-learning This will be a learning Bible ( in developing ... ) for golang~ PS : Currently, all learning content is based on Golang 1.17.5. 主要包含以下

This is a learning poem for golang~
This is a learning poem for golang~

golang-learning-bible This will be a learning Bible ( in developing ... ) for golang~ 中文 | English PS : Currently, all learning content is based on Go

Turtorial - A Hard Fork Of Icexin's Great Gocraft Project Aimed At Learning Basic Programming Tasks Through Turtles
Turtorial - A Hard Fork Of Icexin's Great Gocraft Project Aimed At Learning Basic Programming Tasks Through Turtles

TURTORIAL A voxel sandbox-survival game aimed at teaching the basics of programm

Golang - Learning go aka Flow with the go

golang learning go aka Flow with the go! helpful links tour of go: https://go.de

Learning Hexagonal Pattern with Golang

Marketplace Utility Software yang harus terinstal di komputer Software Versi Golang 1.17+ MariaDB 10.3+ Cara Menjalakan Clone repo ini Buat database d

Comments
  • 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
My ML - A machine learning package based on golang

my_ML a machine learning package based on golang 这是一个基于golang的机器学习库和一些机器学习的数据集,可

luke_luke 1 Feb 15, 2022
Labs from MIT's graduate-level Distributed Systems course

Labs from MIT's graduate-level Distributed Systems course Course website here Lab 1: MapReduce Lab 2: Raft Consensus Algorithm Lab 2A: Raft Leader Ele

Aaron Bauer 0 Jun 20, 2022
This project is a collection of many of the basic tools used on Unix-like operating systems implemented in Go as a learning exercize.

GoUnix This project is a collection of many of the basic tools used on Unix-like operating systems implemented in Go as a learning exercize. The idea

Tom Hanson 65 Jul 21, 2022
Examples of Golang compared to Node.js for learning

This guide full of examples is intended for people learning Go that are coming from Node.js, although the vice versa can work too. This is not meant to be a complete guide and it is assumed that you've gone through the Tour of Go tutorial. This guide is meant to be barely good enough to help you at a high level understand how to do X in Y and doing further learning on your own is of course required.

Miguel Mota 3.5k Jan 9, 2023
100 days of Go learning

This repository is a journal of my path to learning GO. By the end of the 100 days, you should be able to follow along by day and learn Go as well.

Cobra 25 Oct 27, 2022
Golang Learning resources

golang Golang Learning resources Data type detection dataFields interface{} dtype := reflect.TypeOf(dataFields).Kind().String() var c Company fmt.Prin

MD MOSTAIN BILLAH 11 Dec 14, 2022
Contains hundreds of samples for learning Go.

Get Started introduction installation Basics hello scopes imports simple multiple alias lifecycle comments simple multiline documentation semicolons v

Oguzhan Kiyar 102 Dec 15, 2022
Repository for learning GO lang

LearnGOLang Repository for learning GO lang. What is Go? Go is a fast, statically typed compiled language Compiled to machine level code, does not nee

Allan 0 Oct 15, 2021
Learning GO language by building projects

GoLangProjects Projects list Helloworld Variables Userinput Conversion Math, crypto & random Time & Date Pointers Arrays Slices Maps Structures If-Els

Kishan Kr Sharma 2 Dec 5, 2022
Learning and Practice - Go Lang

Go Lang - Learning and Practice All the code stored here is provided by Tour of Go Basics Packages, variables, and functions Flow control statements:

Carlos López 1 Jan 14, 2022