Skip to content

Instantly share code, notes, and snippets.

@fgardavaud
Last active December 13, 2023 20:31
Show Gist options
  • Save fgardavaud/8e573c3870513205f7d13a4517da7e18 to your computer and use it in GitHub Desktop.
Save fgardavaud/8e573c3870513205f7d13a4517da7e18 to your computer and use it in GitHub Desktop.
Read h5 file in macOS

Install programs to add linux-based command line

First install Homebrew on your mac computer. To do that, open terminal and paste following command-line : /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Follow instructions displayed in terminal window.

Reboot your computer.

Now you can install new command line derived from linux system.

install packages to mount ext volume on your computer

Then you have to install package to read hdf5 file format. Paste on terminal : brew install hdf5

it will install hdf5 and all the dependencies on your system.

Read .h5 file

Now you can acces to .h5 file content as .h5 files are such of kind of matrix files containing numeric values.

First, you have to understand how your h5 file is structured.

To do that, type this command line : h5ls -r file_name.h5. You will get the different path of your matrix data.

Then, you can dump the file content to read the numerical values with this command line :

h5dump -d "/path_name" file_name.h5


Enjoy the great power of linux command line on your mac computer !

@toyo97
Copy link

toyo97 commented Jan 12, 2023

Descriptive and synthetic, precisely what I needed, very useful. Perhaps you want to change the file extension to .md so that github renders it correctly. Thanks!

@fgardavaud
Copy link
Author

@toyo97 Thanks for the positive review. I have corrected the extension name. Now, github renders it correctly.

@doughazell
Copy link

Yes just what I was needing for https://github.com/keras-team/keras/blob/v2.13.1/keras/applications/inception_v3.py#L47-L401 weights in '~/.keras/models/inception_v3_weights_tf_dim_ordering_tf_kernels.h5'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment