如何更改HDF5文件的数据结构?

时间:2016-12-08 10:18:51

标签: keras h5py

我想更改现有HDF5文件的数据结构。

目前我感兴趣的信息存储在h5py组中。我想要的是让该组的信息在其自己的HDF5文件中,子结构不变,但没有上层组,以便可以直接访问该信息。

文件的当前上层结构是:

model_weights            Group
optimizer_weights        Group

'model_weights'我感兴趣的小组。

它包含:

batchnormalization_1   type:  <class 'h5py._hl.group.Group'>
   batchnormalization_1_beta   type: <class 'h5py._hl.dataset.Dataset'>
   batchnormalization_1_gamma   type: <class 'h5py._hl.dataset.Dataset'>
   batchnormalization_1_running_mean   type: <class 'h5py._hl.dataset.Dataset'>
   batchnormalization_1_running_std   type: <class 'h5py._hl.dataset.Dataset'>
batchnormalization_2   type:  <class 'h5py._hl.group.Group'>
   batchnormalization_2_beta   type: <class 'h5py._hl.dataset.Dataset'>
   batchnormalization_2_gamma   type: <class 'h5py._hl.dataset.Dataset'>
   batchnormalization_2_running_mean   type: <class 'h5py._hl.dataset.Dataset'>
   batchnormalization_2_running_std   type: <class 'h5py._hl.dataset.Dataset'>
batchnormalization_3   type:  <class 'h5py._hl.group.Group'>
   batchnormalization_3_beta   type: <class 'h5py._hl.dataset.Dataset'>
   batchnormalization_3_gamma   type: <class 'h5py._hl.dataset.Dataset'>
   batchnormalization_3_running_mean   type: <class 'h5py._hl.dataset.Dataset'>
   batchnormalization_3_running_std   type: <class 'h5py._hl.dataset.Dataset'>
batchnormalization_4   type:  <class 'h5py._hl.group.Group'>
   batchnormalization_4_beta   type: <class 'h5py._hl.dataset.Dataset'>
   batchnormalization_4_gamma   type: <class 'h5py._hl.dataset.Dataset'>    
   batchnormalization_4_running_mean   type: <class 'h5py._hl.dataset.Dataset'>
   batchnormalization_4_running_std   type: <class 'h5py._hl.dataset.Dataset'>
batchnormalization_5   type:  <class 'h5py._hl.group.Group'>
   batchnormalization_5_beta   type: <class 'h5py._hl.dataset.Dataset'>
   batchnormalization_5_gamma   type: <class 'h5py._hl.dataset.Dataset'>
   batchnormalization_5_running_mean   type: <class 'h5py._hl.dataset.Dataset'>
   batchnormalization_5_running_std   type: <class 'h5py._hl.dataset.Dataset'>
dense_1   type:  <class 'h5py._hl.group.Group'>
   dense_1_W   type: <class 'h5py._hl.dataset.Dataset'>
   dense_1_b   type: <class 'h5py._hl.dataset.Dataset'>
dense_2   type:  <class 'h5py._hl.group.Group'>
   dense_2_W   type: <class 'h5py._hl.dataset.Dataset'>
   dense_2_b   type: <class 'h5py._hl.dataset.Dataset'>
dense_3   type:  <class 'h5py._hl.group.Group'>
   dense_3_W   type: <class 'h5py._hl.dataset.Dataset'>
   dense_3_b   type: <class 'h5py._hl.dataset.Dataset'>
dense_4   type:  <class 'h5py._hl.group.Group'>
   dense_4_W   type: <class 'h5py._hl.dataset.Dataset'>
   dense_4_b   type: <class 'h5py._hl.dataset.Dataset'>
maxoutdense_1   type:  <class 'h5py._hl.group.Group'>
   maxoutdense_1_W   type: <class 'h5py._hl.dataset.Dataset'>
   maxoutdense_1_b   type: <class 'h5py._hl.dataset.Dataset'>
maxoutdense_2   type:  <class 'h5py._hl.group.Group'>
   maxoutdense_2_W   type: <class 'h5py._hl.dataset.Dataset'>
   maxoutdense_2_b   type: <class 'h5py._hl.dataset.Dataset'>

我更喜欢不使用Keras重新生成此文件(v1.0升级更改了检查点回调的结构),使用新标志仅保存权重。因此,我想知道是否有一种比在每个空文件中插入每个h5py组和数据集更简单的方法。

0 个答案:

没有答案