How to call a second key in a dictionary using Hdf5matrix?

Asked

Viewed 21 times

0

I’m trying to upload a file .h5 using this documentation HDF5Matrix:

test_images = HDF5Matrix(train_path+train_file,'images')

but I’m getting this mistake:

Keyerror: "Unable to open Object (Object 'images' doesn’t exist)"

I know it is necessary to use this syntax to call a second key in a dictionary ['train'] ['images'].

I usually use this instruction to open files .h5:

with h5py.File(train_path+train_file, 'r') as hf:
      train_images = hf['train']['images'][:]

My question is: You can access the second key to use the syntax HDF5Matrix?

Thank you!

1 answer

0


I finally got!

It’s very easy, the type files h5 have this structure:

file
  Group
    Dataset

So if we want to access the Dataset using HDF5Matrix('path/file','dataset'). We just have to call the Group first. This will be how:

from keras.utils import HDF5Matrix

x_data = HDF5Matrix('path/file', 'group/dataset')

Browser other questions tagged

You are not signed in. Login or sign up in order to post.