https://github.com/wamuir/graft
Go language bindings to the TensorFlow C API
https://github.com/wamuir/graft
go golang machine-learning tensorflow
Last synced: about 1 year ago
JSON representation
Go language bindings to the TensorFlow C API
- Host: GitHub
- URL: https://github.com/wamuir/graft
- Owner: wamuir
- License: apache-2.0
- Created: 2021-12-11T10:47:50.000Z (over 4 years ago)
- Default Branch: nightly
- Last Pushed: 2025-03-15T18:16:45.000Z (over 1 year ago)
- Last Synced: 2025-04-07T01:52:22.523Z (about 1 year ago)
- Topics: go, golang, machine-learning, tensorflow
- Language: Go
- Homepage: https://pkg.go.dev/github.com/wamuir/graft
- Size: 3.5 MB
- Stars: 56
- Watchers: 1
- Forks: 3
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Graft
[](https://github.com/tensorflow/tensorflow/tree/nightly)
[](https://github.com/wamuir/graft/actions/workflows/integrate-nightly-changes.yml?query=branch%3Anightly)
[](https://pkg.go.dev/github.com/wamuir/graft/tensorflow)
## About
**Go language bindings to the TensorFlow C API**
Graft contains nightly and release builds of the Go language bindings to the
TensorFlow C API, including Go-compiled TensorFlow protocol buffers and
generated Go wrappers for TensorFlow operations.
Use Graft exactly as you would use the Go bindings found in the main TensorFlow
repo, and with the following import statement: `github.com/wamuir/graft/tensorflow`
## Getting Started
> Note: the Go bindings depend on
> [libtensorflow](https://www.tensorflow.org/install/lang_c), which should be
> downloaded (or compiled) and installed first.
Installation is performed using `go get`:
```sh
go get -u github.com/wamuir/graft/tensorflow/...
```
Hello TensorFlow
```go
package main
import (
tf "github.com/wamuir/graft/tensorflow"
"github.com/wamuir/graft/tensorflow/op"
"fmt"
)
func main() {
// Construct a graph with an operation that produces a string constant.
s := op.NewScope()
c := op.Const(s, "Hello from TensorFlow version " + tf.Version())
graph, err := s.Finalize()
if err != nil {
panic(err)
}
// Execute the graph in a session.
sess, err := tf.NewSession(graph, nil)
if err != nil {
panic(err)
}
output, err := sess.Run(nil, []tf.Output{c}, nil)
if err != nil {
panic(err)
}
fmt.Println(output[0].Value())
}
```
## Credits
Graft is a compilation of [TensorFlow](https://tensorflow.org/code) source
code.