Comments (5)
Thanks a lot to @galeone
it's working now for me
hope for a "go get"-able tensorflow stable go api
from tfgo.
The tensorflow Go package is not a standard Go package, in fact you have to manually download it by your self and switch to the correct branch of the repository.
Have a look at how I do this in the .travis.yml
:
git clone https://github.com/tensorflow/tensorflow $GOPATH/src/github.com/tensorflow/tensorflow/
pushd $GOPATH/src/github.com/tensorflow/tensorflow/tensorflow/go
git checkout r1.14
go build
Let me know if it works for you
from tfgo.
thanks you so much @galeone
I don't really understand the purposes of the 3 last command line you specified.
I'm trying to work in the same way I'm working with other dependencies.
after running the following line i'm getting the sources at my go path.
git clone https://github.com/tensorflow/tensorflow $GOPATH/src/github.com/tensorflow/tensorflow/
now i can import it like this:
import (
tensorflow "github.com/tensorflow/tensorflow/tensorflow/go"
"github.com/tensorflow/tensorflow/tensorflow/go/op"
)
running the following function give me the error like this
func runModel() {
// Construct a graph with an operation that produces a string constant.
s := op.NewScope()
c := op.Const(s, "Hello from TensorFlow version "+tensorflow.Version())
graph, err := s.Finalize()
if err != nil {
panic(err)
}
// Execute the graph in a session.
sess, err := tensorflow.NewSession(graph, nil)
if err != nil {
panic(err)
}
output, err := sess.Run(nil, []tensorflow.Output{c}, nil)
if err != nil {
panic(err)
}
fmt.Println(output[0].Value())
}
error ===>
../../tensorflow/tensorflow/tensorflow/go/saved_model.go:25:2: cannot find package "github.com/tensorflow/tensorflow/tensorflow/go/genop/internal/proto/github.com/tensorflow/tensorflow/tensorflow/go/core" in any of:
/usr/local/Cellar/go/1.13.4/libexec/src/github.com/tensorflow/tensorflow/tensorflow/go/genop/internal/proto/github.com/tensorflow/tensorflow/tensorflow/go/core (from $GOROOT)
/Users/yohai/dev/go/src/github.com/tensorflow/tensorflow/tensorflow/go/genop/internal/proto/github.com/tensorflow/tensorflow/tensorflow/go/core (from $GOPATH)
from tfgo.
also ... a lot of tutorials and post specify running this 2 lines
go get github.com/tensorflow/tensorflow/tensorflow/go
go test github.com/tensorflow/tensorflow/tensorflow/go
this is exactly how I import go packages for use in my code but something going wrong
there is also an opened issue https://github.com/tensorflow/tensorflow/issues/34580 and no one is correcting the issue.
Or maybe I'm missing something ?
from tfgo.
A lot of tutorials do the wrong assumption that the master branch of the TensorFlow repo has a stable Go API. This is false.
The go get
command, simply clones the tensorflow repository in your go path and checks it out to the master
branch; but the master branch is not stable for Go :)
So, you have to manually checkout to a branch that has a stable Go API. In the lines above I did it:
git clone https://github.com/tensorflow/tensorflow $GOPATH/src/github.com/tensorflow/tensorflow/
: I'm cloning the tensorflow repo into the correct path (this is equivalent to the go get command)pushd $GOPATH/src/github.com/tensorflow/tensorflow/tensorflow/go
I'm changing dir and going into thego
package, inside the tensorflow repo I just clonedgit checkout r1.14
I'm changing branch, from master (unstable) tor1.14
(tensorflow 1.14) that has a stable and working Go API.go build
I'm building the go package from sourcesgo test
If you want to be sure that everything works, run go test (inside the same folder) to test the tensorflow/go package
from tfgo.
Related Issues (20)
- so gpu how to use HOT 1
- tf.Variable support HOT 1
- windows installation error HOT 5
- loading model HOT 2
- cc1.exe: sorry, unimplemented: 64-bit mode not compiled in HOT 1
- Error: W tensorflow/core/framework/op_kernel.cc:1745] OP_REQUIRES failed at lookup_table_op.cc:929 : FAILED_PRECONDITION: Table not initialized. HOT 1
- SparseTensor support HOT 2
- Failed to go get tfgo HOT 3
- tensor example support HOT 6
- Potential memory leak on reloading model HOT 8
- libtensorflow.so: .dynsym local symbol at index 3 (>= sh_info of 3) HOT 2
- Matching between output tensor name and prediction HOT 7
- Thread safety HOT 2
- Panic vs Error HOT 2
- Reading jpg image from disk and passing as input to a pretrained model loaded from disk HOT 4
- Error building "Getting Started" example: rebuild TensorFlow with the appropriate compiler flags HOT 5
- Can I use tfgo for tensorflow 2.11.x? HOT 2
- Convert opencv's `mat` to tfgo's `tensor` HOT 7
- Dark Souls level frustration with compilation project with this library HOT 1
- Discrepancy between python and go outputs HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tfgo.