Create dataset from list of json files

Hi all, I’m new to tensorflow, and I’m trying to train a model based on data fetched by a smartwatch sensors. I’ve many json files, and every single file contain an array of arrays. A single file refers to a single sample. How can i create a dataset from this type of data?

Sample of json file:

[
    [
        0.147856,
        0.002688,
        0.108568,
        0.983028
    ],
    [
        0.148294,
        0.002196,
        0.107716,
        0.983056
    ],
    [
        0.148497,
        0.003929,
        0.107291,
        0.983067
    ],
    [
        0.150672,
        0.00348,
        0.106285,
        0.982847
    ],
...
]

Hi @Quiquoqua48,Welcome to TF Forum!

To create a dataset from json files, first read the data from the json file

with open(file_path, 'r') as f:
  data = json.load(f)

Now you can create a dataset using

dataset = tf.data.Dataset.from_tensor_slices(data)

Please refer to this gist for working code example. Thank You.

1 Like