[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-9777":3},{"id":4,"name":5,"fullName":6,"owner":5,"repo":5,"description":7,"homepage":8,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":15,"stars7d":16,"stars30d":17,"stars90d":15,"forks30d":15,"starsTrendScore":15,"compositeScore":18,"rankGlobal":9,"rankLanguage":9,"license":19,"archived":20,"fork":20,"defaultBranch":21,"hasWiki":22,"hasPages":20,"topics":23,"createdAt":9,"pushedAt":9,"updatedAt":39,"readmeContent":40,"aiSummary":41,"trendingCount":15,"starSnapshotCount":15,"syncStatus":42,"lastSyncTime":43,"discoverSource":44},9777,"gorgonia","gorgonia\u002Fgorgonia","Gorgonia is a library that helps facilitate machine learning in Go.","https:\u002F\u002Fgorgonia.org\u002F",null,"Go",5915,450,182,105,0,1,4,64.86,"Apache License 2.0",false,"master",true,[24,25,26,27,28,29,30,31,32,5,33,34,35,36,37,38],"artificial-intelligence","automatic-differentiation","computation-graph","deep-learning","deep-neural-networks","deeplearning","differentiation","go","golang","gradient-descent","graph-computation","hacktoberfest","machine-learning","neural-network","symbolic-differentiation","2026-06-12 04:00:46","![Logo](https:\u002F\u002Fraw.githubusercontent.com\u002Fgorgonia\u002Fgorgonia\u002Fmaster\u002Fmedia\u002FLogo_horizontal_small.png)\n\n[![GoDoc](https:\u002F\u002Fgodoc.org\u002Fgorgonia.org\u002Fgorgonia?status.svg)](https:\u002F\u002Fgodoc.org\u002Fgorgonia.org\u002Fgorgonia) [![GitHub version](https:\u002F\u002Fbadge.fury.io\u002Fgh\u002Fgorgonia%2Fgorgonia.svg)](https:\u002F\u002Fbadge.fury.io\u002Fgh\u002Fgorgonia%2Fgorgonia) \n![Build and Tests](https:\u002F\u002Fgithub.com\u002Fgorgonia\u002Fgorgonia\u002Fworkflows\u002FBuild%20and%20Tests%20on%20Linux\u002Famd64\u002Fbadge.svg)\n[![codecov](https:\u002F\u002Fcodecov.io\u002Fgh\u002Fgorgonia\u002Fgorgonia\u002Fbranch\u002Fmaster\u002Fgraph\u002Fbadge.svg)](https:\u002F\u002Fcodecov.io\u002Fgh\u002Fgorgonia\u002Fgorgonia)\n[![Go Report Card](https:\u002F\u002Fgoreportcard.com\u002Fbadge\u002Fgorgonia.org\u002Fgorgonia)](https:\u002F\u002Fgoreportcard.com\u002Freport\u002Fgorgonia.org\u002Fgorgonia) [![unstable](http:\u002F\u002Fbadges.github.io\u002Fstability-badges\u002Fdist\u002Funstable.svg)](http:\u002F\u002Fgithub.com\u002Fbadges\u002Fstability-badges)\n\n#\n\nGorgonia is a library that helps facilitate machine learning in Go. Write and evaluate mathematical equations involving multidimensional arrays easily. If this sounds like [Theano](http:\u002F\u002Fdeeplearning.net\u002Fsoftware\u002Ftheano\u002F) or [TensorFlow](https:\u002F\u002Fwww.tensorflow.org\u002F), it's because the idea is quite similar. Specifically, the library is pretty low-level, like Theano, but has higher goals like Tensorflow.\n\nGorgonia:\n\n* Can perform automatic differentiation\n* Can perform symbolic differentiation\n* Can perform gradient descent optimizations\n* Can perform numerical stabilization\n* Provides a number of convenience functions to help create neural networks\n* Is fairly quick (comparable to Theano and TensorFlow speed)\n* Supports CUDA\u002FGPGPU computation (OpenCL not yet supported, send a pull request)\n* Will support distributed computing\n\n# Goals #\n\nThe primary goal for Gorgonia is to be a *highly performant* machine learning\u002Fgraph 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.\n\nThe secondary goal for Gorgonia is to provide a platform for the exploration of non-standard deep-learning and neural network-related things. This includes things like neo-hebbian learning, corner-cutting algorithms, evolutionary algorithms, and the like.\n\n# Why Use Gorgonia? #\n\nThe main reason to use Gorgonia is developer comfort. If you're using a Go stack extensively, now you have access to the ability to create production-ready machine learning systems in an environment that you are already familiar with and comfortable with.\n\nML\u002FAI at large is usually split into two stages: the experimental stage where one builds various models, tests, and retests; and the deployed state where a model after being tested and played with, is deployed. This necessitates different roles like data scientist and data engineer.\n\nTypically the two phases have different tools: Python ([PyTorch](http:\u002F\u002Fpytorch.org\u002F), etc) is commonly used for the experimental stage, and then the model is rewritten in some more performant language like C++ (using [dlib](http:\u002F\u002Fdlib.net\u002Fml.html), [mlpack](http:\u002F\u002Fmlpack.org) etc). Of course, nowadays the gap is closing and people frequently share the tools between them. Tensorflow is one such tool that bridges the gap.\n\nGorgonia aims to do the same but for the Go environment. Gorgonia is currently fairly performant - its speeds are comparable to PyTorch's and Tensorflow's  CPU implementations. GPU implementations are a bit finicky to compare due to the heavy CGO tax, but rest assured that this is an area of active improvement.\n\n# Getting started\n\n## Installation #\n\nThe package is go-gettable: `go get -u gorgonia.org\u002Fgorgonia`.\n\nGorgonia is compatible with Go modules.\n\n## Documentation\n\nUp-to-date documentation, references, and tutorials are present on the official Gorgonia website at [https:\u002F\u002Fgorgonia.org](https:\u002F\u002Fgorgonia.org).\n\n## Keeping Updated\n\nGorgonia's project has a [Slack channel on gopherslack](https:\u002F\u002Fgophers.slack.com\u002Fmessages\u002Fgorgonia\u002F), as well as a [Twitter account](https:\u002F\u002Ftwitter.com\u002FgorgoniaML). Official updates and announcements will be posted to those two sites.\n\n## Usage\n\nGorgonia works by creating a computation graph and then executing it. Think of it as a programming language, but is limited to mathematical functions, and has no branching capability (no if\u002Fthen or loops). In fact, this is the dominant paradigm that the user should be used to thinking about. The computation graph is an [AST](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FAbstract_syntax_tree).\n\nMicrosoft's [CNTK](https:\u002F\u002Fgithub.com\u002FMicrosoft\u002FCNTK), with its BrainScript, is perhaps the best at exemplifying the idea that building a computation graph and running the computation graphs are different things and that the user should be in different modes of thought when going about them.\n\nWhilst Gorgonia's implementation doesn't enforce the separation of thought as far as CNTK's BrainScript does, the syntax does help a little bit.\n\nHere's an example - say you want to define a math expression `z = x + y`. Here's how you'd do it:\n\n[embedmd]:# (example_basic_test.go)\n```Go\npackage gorgonia_test\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\n\t. \"gorgonia.org\u002Fgorgonia\"\n)\n\n\u002F\u002F Basic example of representing mathematical equations as graphs.\n\u002F\u002F\n\u002F\u002F In this example, we want to represent the following equation\n\u002F\u002F\t\tz = x + y\nfunc Example_basic() {\n\tg := NewGraph()\n\n\tvar x, y, z *Node\n\tvar err error\n\n\t\u002F\u002F define the expression\n\tx = NewScalar(g, Float64, WithName(\"x\"))\n\ty = NewScalar(g, Float64, WithName(\"y\"))\n\tif z, err = Add(x, y); err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t\u002F\u002F create a VM to run the program on\n\tmachine := NewTapeMachine(g)\n\tdefer machine.Close()\n\n\t\u002F\u002F set initial values then run\n\tLet(x, 2.0)\n\tLet(y, 2.5)\n\tif err = machine.RunAll(); err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tfmt.Printf(\"%v\", z.Value())\n\t\u002F\u002F Output: 4.5\n}\n```\n\nYou might note that it's a little more verbose than other packages of similar nature. For example, instead of compiling to a callable function, Gorgonia specifically compiles into a `*program` which requires a `*TapeMachine` to run. It also requires manual a `Let(...)` call.\n\nThe author would like to contend that this is a Good Thing - to shift one's thinking to machine-based thinking. It helps a lot in figuring out where things might go wrong.\n\nAdditionally, there is no support for branching - that is to say, there are no conditionals (if\u002Felse) or loops. The aim is not to build a Turing-complete computer.\n\n---\nMore examples are present in the `example` subfolder of the project, and step-by-step tutorials are present on the [main website](https:\u002F\u002Fgorgonia.org\u002Ftutorials\u002F)\n\n## Using CUDA ##\n\nGorgonia comes with CUDA support out of the box.\nPlease see the reference documentation about how cuda works on [the Gorgonia.org](https:\u002F\u002Fgorgonia.org\u002Freference\u002Fcuda\u002F) website, or jump to the [tutorial](https:\u002F\u002Fgorgonia.org\u002Ftutorials\u002Fmnist-cuda\u002F).\n\n# About Gorgonia's development process\n\n## Versioning ##\n\nWe use [semver 2.0.0](http:\u002F\u002Fsemver.org\u002F) for our versioning. Before 1.0, Gorgonia's APIs are expected to change quite a bit. API is defined by the exported functions, variables, and methods. For the developers' sanity, there are minor differences to SemVer that we will apply before version 1.0. They are enumerated below:\n\n* The MINOR number will be incremented every time there is a deleterious break in API. This means any deletion or any change in function signature or interface methods will lead to a change in the MINOR number.\n* Additive changes will NOT change the MINOR version number before version 1.0. This means that if new functionality were added that does not break the way you use Gorgonia, there would not be an increment in the MINOR version. There will be an increment in the PATCH version.\n\n### API Stability #\nGorgonia's API is as of right now, not considered stable. It will be stable from version 1.0 forward.\n\n\n## Go Version Support ##\n\nGorgonia supports 2 versions below the Master branch of Go. This means Gorgonia will support the current released version of Go, and up to 4 previous versions - providing something doesn't break. Where possible a shim will be provided (for things like new `sort` APIs or `math\u002Fbits` which came out in Go 1.9).\n\nThe current version of Go is 1.13.1. The earliest version Gorgonia supports is Go 1.11.x but Gonum supports only 1.12+. Therefore, the minimum Go version to run the master branch is Go > 1.12.\n\n## Hardware and OS supported ##\n\nGorgonia runs on :\n- linux\u002FAMD64\n- linux\u002FARM7\n- linux\u002FARM64\n- win32\u002FAMD64\n- darwin\u002FAMD64\n- freeBSD\u002FAMD64\n\nIf you have tested Gorgonia on other platforms, please update this list.\n\n## Hardware acceleration\n\nGorgonia uses some pure assembler instructions to accelerate some mathematical operations. Unfortunately, only amd64 is supported.\n\n\n# Contributing #\n\nObviously, since you are most probably reading this on Github, Github will form the major part of the workflow for contributing to this package.\n\nSee also: [CONTRIBUTING.md](CONTRIBUTING.md)\n\n\n## Contributors and Significant Contributors ##\nAll contributions are welcome. However, there is a new class of contributors, called Significant Contributors.\n\nA Significant Contributor has shown *a deep understanding* of how the library works and\u002For its environs.  Here are examples of what constitutes a Significant Contribution:\n\n* Wrote significant amounts of documentation on **why**\u002Fthe mechanics of particular functions\u002Fmethods and how the different parts affect one another\n* Wrote code and tests around the more intricately connected parts of Gorgonia\n* Wrote code and tests, and had at least 5 pull requests accepted\n* Provided expert analysis on parts of the package (for example, you may be a floating point operations expert who optimized one function)\n* Answered at least 10 support questions.\n\nThe significant Contributors list will be updated once a month (if anyone even uses Gorgonia that is).\n\n# How To Get Support #\nThe best way of support right now is to open a [ticket on Github](https:\u002F\u002Fgithub.com\u002Fgorgonia\u002Fgorgonia\u002Fissues\u002Fnew).\n\n# Frequently Asked Questions #\n\n### Why are there seemingly random `runtime.GC()` calls in the tests? ###\n\nThe answer to this is simple - the design of the package uses CUDA in a particular way: specifically, a CUDA device and context are tied to a `VM`, instead of at the package level. This means for every `VM` created, a different CUDA context is created per device per `VM`. This way all the operations will play nicely with other applications that may be using CUDA (this needs to be stress-tested, however).\n\nThe CUDA contexts are only destroyed when the `VM` gets garbage collected (with the help of a finalizer function). In the tests, about 100 `VM`s get created, and garbage collection for the most part can be considered random. This leads to cases where the GPU runs out of memory as there are too many contexts being used.\n\nTherefore at the end of any tests that may use GPU, a `runtime.GC()` call is made to force garbage collection, freeing GPU memories.\n\nIn production, one is unlikely to start that many `VM`s, therefore it's not a problem. If there is, open a ticket on GitHub, and we'll look into adding a `Finish()` method for the `VM`s.\n\n\n# Licence #\n\nGorgonia is licensed under a variant of Apache 2.0. It's the same as the Apache 2.0 Licence, except not being able to commercially profit directly from the package unless you're a Significant Contributor (for example, providing commercial support for the package). It's perfectly fine to profit directly from a derivative of Gorgonia (for example, if you use Gorgonia as a library in your product)\n\nEveryone is still allowed to use Gorgonia for commercial purposes (for example: using it in software for your business).\n\n## Dependencies ##\n\nThere are very few dependencies that Gorgonia uses - and they're all pretty stable, so as of now there isn't a need for vendoring tools. These are the list of external packages that Gorgonia calls, ranked in order of reliance that this package has (sub-packages are omitted):\n\n|Package|Used For|Vitality|Notes|Licence|\n|-------|--------|--------|-----|-------|\n|[gonum\u002Fgraph](https:\u002F\u002Fgithub.com\u002Fgonum\u002Fgonum\u002Ftree\u002Fmaster\u002Fgraph)| Sorting `*ExprGraph`| Vital. Removal means Gorgonia will not work | Development of Gorgonia is committed to keeping up with the most updated version|[gonum license](https:\u002F\u002Fgithub.com\u002Fgonum\u002Flicense) (MIT\u002FBSD-like)|\n|[gonum\u002Fblas](https:\u002F\u002Fgithub.com\u002Fgonum\u002Fgonum\u002Ftree\u002Fmaster\u002Fblas)|Tensor subpackage linear algebra operations|Vital. Removal means Gorgonial will not work|Development of Gorgonia is committed to keeping up with the most updated version|[gonum license](https:\u002F\u002Fgithub.com\u002Fgonum\u002Flicense) (MIT\u002FBSD-like)|\n|[cu](https:\u002F\u002Fgorgonia.org\u002Fcu)| CUDA drivers | Needed for CUDA operations | Same maintainer as Gorgonia | MIT\u002FBSD-like|\n|[math32](https:\u002F\u002Fgithub.com\u002Fchewxy\u002Fmath32)|`float32` operations|Can be replaced by `float32(math.XXX(float64(x)))`|Same maintainer as Gorgonia, same API as the built-in `math` package|MIT\u002FBSD-like|\n|[hm](https:\u002F\u002Fgithub.com\u002Fchewxy\u002Fhm)|Type system for Gorgonia|Gorgonia's graphs are pretty tightly coupled with the type system | Same maintainer as Gorgonia | MIT\u002FBSD-like|\n|[vecf64](https:\u002F\u002Fgorgonia.org\u002Fvecf64)| optimized `[]float64` operations | Can be generated in the `tensor\u002Fgenlib` package. However, plenty of optimizations have been made\u002Fwill be made | Same maintainer as Gorgonia | MIT\u002FBSD-like|\n|[vecf32](https:\u002F\u002Fgorgonia.org\u002Fvecf32)| optimized `[]float32` operations | Can be generated in the `tensor\u002Fgenlib` package. However, plenty of optimizations have been made\u002Fwill be made | Same maintainer as Gorgonia | MIT\u002FBSD-like|\n|[set](https:\u002F\u002Fgithub.com\u002Fxtgo\u002Fset)|Various set operations|Can be easily replaced|Stable API for the past 1 year|[set licence](https:\u002F\u002Fgithub.com\u002Fxtgo\u002Fset\u002Fblob\u002Fmaster\u002FLICENSE) (MIT\u002FBSD-like)|\n|[gographviz](https:\u002F\u002Fgithub.com\u002Fawalterschulze\u002Fgographviz)|Used for printing graphs|Graph printing is only vital to debugging. Gorgonia can survive without, but with a major (but arguably nonvital) feature loss|Last update 12th April 2017|[gographviz license](https:\u002F\u002Fgithub.com\u002Fawalterschulze\u002Fgographviz\u002Fblob\u002Fmaster\u002FLICENSE) (Apache 2.0)|\n|[rng](https:\u002F\u002Fgithub.com\u002Fleesper\u002Fgo_rng)|Used to implement helper functions to generate initial weights|Can be replaced fairly easily. Gorgonia can do without the convenience functions too||[rng license](https:\u002F\u002Fgithub.com\u002Fleesper\u002Fgo_rng\u002Fblob\u002Fmaster\u002FLICENSE) (Apache 2.0)|\n|[errors](https:\u002F\u002Fgithub.com\u002Fpkg\u002Ferrors)|Error wrapping|Gorgonia won't die without it. In fact Gorgonia has also used [goerrors\u002Ferrors](https:\u002F\u002Fgithub.com\u002Fgo-errors\u002Ferrors) in the past.|Stable API for the past 6 months|[errors licence](https:\u002F\u002Fgithub.com\u002Fpkg\u002Ferrors\u002Fblob\u002Fmaster\u002FLICENSE) (MIT\u002FBSD-like)|\n|[gonum\u002Fmat](http:\u002F\u002Fgithub.com\u002Fgonum\u002Fgonum)|Compatibility between `Tensor` and Gonum's Matrix|Development of Gorgonia is committed to keeping up with the most updated version||[gonum license](https:\u002F\u002Fgithub.com\u002Fgonum\u002Flicense) (MIT\u002FBSD-like)|\n|[testify\u002Fassert](https:\u002F\u002Fgithub.com\u002Fstretchr\u002Ftestify)|Testing|Can do without but will be a massive pain in the ass to test||[testify license](https:\u002F\u002Fgithub.com\u002Fstretchr\u002Ftestify\u002Fblob\u002Fmaster\u002FLICENSE) (MIT\u002FBSD-like)|\n\n\n## Various Other Copyright Notices ##\n\nThese are the packages and libraries that inspired and were adapted from in the process of writing Gorgonia (the Go packages that were used were already declared above):\n\n| Source | How it's Used | Licence |\n|------|---|-------|\n| Numpy  | Inspired large portions. Directly adapted algorithms for a few methods (explicitly labeled in the docs) | MIT\u002FBSD-like. [Numpy Licence](https:\u002F\u002Fgithub.com\u002Fnumpy\u002Fnumpy\u002Fblob\u002Fmaster\u002FLICENSE.txt) |\n| Theano | Inspired large portions. (Unsure: number of directly adapted algorithms) | MIT\u002FBSD-like [Theano's license](http:\u002F\u002Fdeeplearning.net\u002Fsoftware\u002Ftheano\u002FLICENSE.html) |\n| Caffe | `im2col` and `col2im` directly taken from Caffe. Convolution algorithms inspired by the original Caffee methods | [Caffe Licence](https:\u002F\u002Fgithub.com\u002FBVLC\u002Fcaffe\u002Fblob\u002Fmaster\u002FLICENSE)\n","Gorgonia是一个用于Go语言的机器学习库。它支持自动微分、符号微分、梯度下降优化以及数值稳定化等核心功能，并提供了一系列便捷函数以帮助创建神经网络，性能与Theano和TensorFlow相当，同时支持CUDA\u002FGPGPU计算。该库旨在为开发者提供一个既高效又能跨多台机器扩展的图计算平台，特别适合那些已经在使用Go技术栈并希望在熟悉的环境中构建生产级机器学习系统的团队或个人。此外，Gorgonia还鼓励探索非标准深度学习方法，如新赫布学习规则、进化算法等实验性研究。",2,"2026-06-11 03:24:40","top_topic"]