kse-01/tensorflow/tensorflow/go
github-classroom[bot] 1122cdd8b0
Initial commit
2023-10-09 11:37:31 +00:00
..
genop Initial commit 2023-10-09 11:37:31 +00:00
op Initial commit 2023-10-09 11:37:31 +00:00
android.go Initial commit 2023-10-09 11:37:31 +00:00
attrs.go Initial commit 2023-10-09 11:37:31 +00:00
attrs_test.go Initial commit 2023-10-09 11:37:31 +00:00
BUILD Initial commit 2023-10-09 11:37:31 +00:00
context.go Initial commit 2023-10-09 11:37:31 +00:00
context_test.go Initial commit 2023-10-09 11:37:31 +00:00
doc.go Initial commit 2023-10-09 11:37:31 +00:00
example_inception_inference_test.go Initial commit 2023-10-09 11:37:31 +00:00
graph.go Initial commit 2023-10-09 11:37:31 +00:00
graph_test.go Initial commit 2023-10-09 11:37:31 +00:00
lib.go Initial commit 2023-10-09 11:37:31 +00:00
operation.go Initial commit 2023-10-09 11:37:31 +00:00
operation_test.go Initial commit 2023-10-09 11:37:31 +00:00
README.md Initial commit 2023-10-09 11:37:31 +00:00
saved_model.go Initial commit 2023-10-09 11:37:31 +00:00
saved_model_test.go Initial commit 2023-10-09 11:37:31 +00:00
session.go Initial commit 2023-10-09 11:37:31 +00:00
session_test.go Initial commit 2023-10-09 11:37:31 +00:00
shape.go Initial commit 2023-10-09 11:37:31 +00:00
shape_test.go Initial commit 2023-10-09 11:37:31 +00:00
signature.go Initial commit 2023-10-09 11:37:31 +00:00
signature_test.go Initial commit 2023-10-09 11:37:31 +00:00
status.go Initial commit 2023-10-09 11:37:31 +00:00
tensor.go Initial commit 2023-10-09 11:37:31 +00:00
tensor_handle.go Initial commit 2023-10-09 11:37:31 +00:00
tensor_handle_test.go Initial commit 2023-10-09 11:37:31 +00:00
tensor_test.go Initial commit 2023-10-09 11:37:31 +00:00
test.sh Initial commit 2023-10-09 11:37:31 +00:00
util_test.go Initial commit 2023-10-09 11:37:31 +00:00
version.go Initial commit 2023-10-09 11:37:31 +00:00

TensorFlow in Go

Construct and execute TensorFlow graphs in Go.

GoDoc

WARNING: The API defined in this package is not stable and can change without notice. The same goes for the package path: (github.com/tensorflow/tensorflow/tensorflow/go).

Quickstart

Refer to Installing TensorFlow for Go

Building the TensorFlow C library from source

If the "Quickstart" instructions above do not work (perhaps the release archives are not available for your operating system or architecture, or you're using a different version of CUDA/cuDNN), then the TensorFlow C library must be built from source.

Prerequisites

Build

  1. Download the source code

    go get -d github.com/tensorflow/tensorflow/tensorflow/go
    
  2. Build the TensorFlow C library:

    cd ${GOPATH}/src/github.com/tensorflow/tensorflow
    ./configure
    bazel build -c opt //tensorflow:libtensorflow.so
    

    This can take a while (tens of minutes, more if also building for GPU).

  3. Make libtensorflow.so and libtensorflow_framework.so available to the linker. This can be done by either:

    a. Copying it to a system location, e.g.,

    sudo cp ${GOPATH}/src/github.com/tensorflow/tensorflow/bazel-bin/tensorflow/libtensorflow.so /usr/local/lib
    sudo cp ${GOPATH}/src/github.com/tensorflow/tensorflow/bazel-bin/tensorflow/libtensorflow_framework.so /usr/local/lib
    

    OR

    b. Setting environment variables:

    export LIBRARY_PATH=${GOPATH}/src/github.com/tensorflow/tensorflow/bazel-bin/tensorflow
    # Linux
    export LD_LIBRARY_PATH=${GOPATH}/src/github.com/tensorflow/tensorflow/bazel-bin/tensorflow
    # OS X
    export DYLD_LIBRARY_PATH=${GOPATH}/src/github.com/tensorflow/tensorflow/bazel-bin/tensorflow
    
  4. Build and test:

    go generate github.com/tensorflow/tensorflow/tensorflow/go/op
    go test github.com/tensorflow/tensorflow/tensorflow/go
    

Generate wrapper functions for ops

Go functions corresponding to TensorFlow operations are generated in op/wrappers.go. To regenerate them:

Prerequisites:

go generate github.com/tensorflow/tensorflow/tensorflow/go/op

Support

Use stackoverflow and/or Github issues.

Contributions

Contributions are welcome. If making any signification changes, probably best to discuss on a Github issue before investing too much time. Github pull requests are used for contributions.