在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:gorgonia/gorgonia开源软件地址:https://github.com/gorgonia/gorgonia开源编程语言:Go 96.4%开源软件介绍:Gorgonia is a library that helps facilitate machine learning in Go. Write and evaluate mathematical equations involving multidimensional arrays easily. If this sounds like Theano or TensorFlow, it's because the idea is quite similar. Specifically, the library is pretty low-level, like Theano, but has higher goals like Tensorflow. Gorgonia:
GoalsThe 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. Why Use Gorgonia?The 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 and comfortable with. ML/AI at large is usually split into two stages: the experimental stage where one builds various models, test and retest; and the deployed state where a model after being tested and played with, is deployed. This necessitate different roles like data scientist and data engineer. Typically the two phases have different tools: Python (PyTorch, etc) is commonly used for the experimental stage, and then the model is rewritten in some more performant language like C++ (using dlib, mlpack 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. Gorgonia 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 finnicky to compare due to the heavy cgo tax, but rest assured that this is an area of active improvement. Getting startedInstallationThe package is go-gettable: Gorgonia is compatible with go modules. DocumentationUp-to-date documentation, references and tutorials are present on the official Gorgonia website at https://gorgonia.org. Keeping UpdatedGorgonia's project has a Slack channel on gopherslack, as well as a Twitter account. Official updates and announcements will be posted to those two sites. UsageGorgonia 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/then or loops). In fact this is the dominant paradigm that the user should be used to thinking about. The computation graph is an AST. Microsoft's CNTK, with its BrainScript, is perhaps the best at exemplifying the idea that building of a computation graph and running of the computation graphs are different things, and that the user should be in different modes of thoughts when going about them. Whilst Gorgonia's implementation doesn't enforce the separation of thought as far as CNTK's BrainScript does, the syntax does help a little bit. Here's an example - say you want to define a math expression 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
} You 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 The author would like to contend that this is a Good Thing - to shift one's thinking to a machine-based thinking. It helps a lot in figuring out where things might go wrong. Additionally, there are no support for branching - that is to say there are no conditionals (if/else) or loops. The aim is not to build a Turing-complete computer. More examples are present in the Using CUDAGorgonia comes with CUDA support out of the box. Please see the reference documentation about how cuda works on the Gorgonia.org website, or jump to the tutorial. About Gorgonia's development processVersioningWe use semver 2.0.0 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 prior to version 1.0. They are enumerated below:
API StabilityGorgonia's API is as of right now, not considered stable. It will be stable from version 1.0 forwards. Go Version SupportGorgonia 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 The 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. Hardware and OS supportedGorgonia runs on :
If you have tested gorgonia on other platform, please update this list. Hardware accelerationGorgonia use some pure assembler instructions to accelerate somes mathematical operations. Unfortunately, only amd64 is supported. ContributingObviously since you are most probably reading this on Github, Github will form the major part of the workflow for contributing to this package. See also: CONTRIBUTING.md Contributors and Significant ContributorsAll contributions are welcome. However, there is a new class of contributor, called Significant Contributors. A Significant Contributor is one who has shown deep understanding of how the library works and/or its environs. Here are examples of what constitutes a Significant Contribution:
Significant Contributors list will be updated once a month (if anyone even uses Gorgonia that is). How To Get SupportThe best way of support right now is to open a ticket on Github. Frequently Asked Questions
Why are there seemingly random |
Package | Used For | Vitality | Notes | Licence |
---|---|---|---|---|
gonum/graph | Sorting *ExprGraph |
Vital. Removal means Gorgonia will not work | Development of Gorgonia is committed to keeping up with the most updated version | gonum license (MIT/BSD-like) |
gonum/blas | 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 (MIT/BSD-like) |
cu | CUDA drivers | Needed for CUDA operations | Same maintainer as Gorgonia | MIT/BSD-like |
math32 | float32 operations |
Can be replaced by float32(math.XXX(float64(x))) |
Same maintainer as Gorgonia, same API as the built in math package |
MIT/BSD-like |
hm | Type system for Gorgonia | Gorgonia's graphs are pretty tightly coupled with the type system | Same maintainer as Gorgonia | MIT/BSD-like |
vecf64 | optimized []float64 operations |
Can be generated in the tensor/genlib package. However, plenty of optimizations have been made/will be made |
Same maintainer as Gorgonia | MIT/BSD-like |
vecf32 | optimized []float32 operations |
Can be generated in the tensor/genlib package. However, plenty of optimizations have been made/will be made |
Same maintainer as Gorgonia | MIT/BSD-like |
set | Various set operations | Can be easily replaced | Stable API for the past 1 year | set licence (MIT/BSD-like) |
gographviz | 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 licence (Apache 2.0) |
rng | Used to implement helper functions to generate initial weights | Can be replaced fairly easily. Gorgonia can do without the convenience functions too | rng licence (Apache 2.0) | |
errors | Error wrapping | Gorgonia won't die without it. In fact Gorgonia has also used goerrors/errors in the past. | Stable API for the past 6 months | errors licence (MIT/BSD-like) |
gonum/mat | Compatibility between Tensor and Gonum's Matrix |
Development of Gorgonia is committed to keeping up with the most updated version | gonum license (MIT/BSD-like) | |
testify/assert | Testing | Can do without but will be a massive pain in the ass to test | testify licence (MIT/BSD-like) |
These are the packages and libraries which inspired and were adapted from in the process of writing Gorgonia (the Go packages that were used were already declared above):
Source | How it's Used | Licence |
---|---|---|
Numpy | Inspired large portions. Directly adapted algorithms for a few methods (explicitly labelled in the docs) | MIT/BSD-like. Numpy Licence |
Theano | Inspired large portions. (Unsure: number of directly adapted algorithms) | MIT/BSD-like Theano's licence |
Caffe | im2col and col2im directly taken from Caffe. Convolution algorithms inspired by the original Caffee methods |
Caffe Licence |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论