Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tensor DT_STRING createBuffer() doesn't work #249

Closed
lakshmanok opened this issue Jul 6, 2016 · 4 comments
Closed

Tensor DT_STRING createBuffer() doesn't work #249

lakshmanok opened this issue Jul 6, 2016 · 4 comments

Comments

@lakshmanok
Copy link

This code:

           Tensor fn = new Tensor(tensorflow.DT_STRING, new TensorShape(1));
    CharBuffer buffer = fn.createBuffer();

results in a null buffer. However,

            Tensor fn = new Tensor(tensorflow.DT_FLOAT, new TensorShape(1));
    FloatBuffer buffer = fn.createBuffer();

works fine.

@saudet
Copy link
Member

saudet commented Jul 8, 2016

DT_STRING data cannot be represented by primitive types in Java, so we need something else to access it. I've created a StringArray helper class for that in the commit above, so we can do stuff like this:

Tensor x = new Tensor(DT_STRING, new TensorShape(2, 2));
StringArray a = x.createStringArray();
a.position(0).put("foo");
a.position(3).put("bar");
System.out.println(a.position(0)); // prints "foo"

Let me know if that satisfies your needs!

@lakshmanok
Copy link
Author

Thanks ... tensorflow.jar that I get from Maven doesn't seem to have been updated?

@saudet
Copy link
Member

saudet commented Jul 8, 2016

Need to rebuild from source...

@saudet
Copy link
Member

saudet commented Jul 31, 2016

Update binaries are now on the central:
http://search.maven.org/#artifactdetails%7Corg.bytedeco.javacpp-presets%7Ctensorflow%7C0.9.0-1.2%7Cjar
Thanks for reporting this issue!

@saudet saudet closed this as completed Jul 31, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants