title: Creating and accessing datasets in an HDF5 file
body: <p>I am trying to create an HDF5 file with two datasets, 'data' and 'label'. When I tried to access the said file, however, I got an error as follows: </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>Traceback (most recent call last):
    File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.4\helpers\pydev\pydevd.py", line 1664, in &lt;module&gt;
      main()
    File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.4\helpers\pydev\pydevd.py", line 1658, in main
      globals = debugger.run(setup['file'], None, None, is_module)
    File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.4\helpers\pydev\pydevd.py", line 1068, in run
      pydev_imports.execfile(file, globals, locals)  # execute the script
    File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.4\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
      exec(compile(contents+"\n", file, 'exec'), glob, loc)
    File "C:/pycharm/Input_Pipeline.py", line 140, in &lt;module&gt;
      data_h5 = f['data'][:]
    File "h5py\_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
    File "h5py\_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
    File "C:\Users\u20x47\PycharmProjects\PCL\venv\lib\site-packages\h5py\_hl\group.py", line 177, in __getitem__
      oid = h5o.open(self.id, self._e(name), lapl=self._lapl)
    File "h5py\_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
    File "h5py\_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
    File "h5py\h5o.pyx", line 190, in h5py.h5o.open
  ValueError: Not a location (invalid object ID)</code></pre>
  </div>
  </div>
  </p>
  
  <p>Code used to create the dataset: </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>h5_file.create_dataset('data', data=data_x, compression='gzip', compression_opts=4, dtype='float32')
  h5_file.create_dataset('label', data=label, compression='gzip', compression_opts=1, dtype='uint8')
  
  data_x an array of arrays. Each element in data_x is a 3D array of 1024 elements. 
  label is an array of arrays as well. Each element is a 1D array of 1 element. </code></pre>
  </div>
  </div>
  </p>
  
  <p>Code to access the said file:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>f = h5_file
  data_h5 = f['data'][:]
  label_h5 = f['label'][:]
  print (data_h5, label_h5)</code></pre>
  </div>
  </div>
  </p>
  
  <p>How can I fix this? Is this a syntax error or a logical one? </p>