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

Issue when reading file with tensorflow #27

Open
aurelio-amerio opened this issue Oct 12, 2022 · 0 comments
Open

Issue when reading file with tensorflow #27

aurelio-amerio opened this issue Oct 12, 2022 · 0 comments

Comments

@aurelio-amerio
Copy link
Contributor

Hello, I'm having some problems when trying to read the file with tensorflow.
While it seems that it is possible to correctly read tfrecord files generated with tensorflow, reading tfrecord files generated with this library with tensorflow leads to some problems.

In particular, for some reasons tensorflow doesn't correctly pick the feature fields, and it parses all the data as if there were only one feature (if they are of the same type) or it picks only one field at random.
To reproduce the error, create a tfrecord file in julia with the example:

using TFRecord

n = 10
f1 = rand(Bool, n)
f2 = rand(1:5, n)
f3 = rand(("cat", "dog", "chicken", "horse", "goat"), n)
f4 = rand(Float32, n)

TFRecord.write(
    "example.tfrecord",
    (
        Dict(
            "feature1" => f1[i],
            "feature2" => f2[i],
            "feature3" => f3[i],
            "feature4" => f4[i],
        )
        for i in 1:n
    )
)

And try to read it back using tensorflow in python:

import tensorflow as tf
import numpy as np

raw_dataset = tf.data.TFRecordDataset("example.tfrecord")

# take the first example and print the content
for raw_record in raw_dataset.take(1):
    example = tf.train.Example()
    example.ParseFromString(raw_record.numpy())
    print(example)

Could you please take a look at this? Unfortunately I don't know enough of protobuf and TFRecord files to be able to correctly solve this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant