3

I've read that HDF5 format can be used to save machine learning models. However, when using a trained CNNClassifier instance from sktime:

import h5py
from sktime.classification.deep_learning.cnn import CNNClassifier
cnn = CNNClassifier(n_epochs=100, batch_size=4) # it runs for Ne epochs
with h5py.File(
        "test.h5",
        "w"
    ) as f:
    dataset_cnn = f.create_dataset("cnn", data=cnn)

However, I got the following error:

Traceback (most recent call last):
  File "<string>", line 5, in <module>
  File "/home/tapyu/.cache/pypoetry/virtualenvs/tscnn-PNsUTi5L-py3.10/lib/python3.10/site-packages/h5py/_hl/group.py", line 183, in create_dataset
    dsid = dataset.make_new_dset(group, shape, dtype, data, name, **kwds)
  File "/home/tapyu/.cache/pypoetry/virtualenvs/tscnn-PNsUTi5L-py3.10/lib/python3.10/site-packages/h5py/_hl/dataset.py", line 86, in make_new_dset
    tid = h5t.py_create(dtype, logical=1)
  File "h5py/h5t.pyx", line 1658, in h5py.h5t.py_create
  File "h5py/h5t.pyx", line 1682, in h5py.h5t.py_create
  File "h5py/h5t.pyx", line 1742, in h5py.h5t.py_create
TypeError: Object dtype dtype('O') has no native HDF5 equivalent

After all, which ML models can be saved using HDF5?

1 Answers1

4

ML frameworks with native support for saving models as HDF5:

ML frameworks without native support for saving models as HDF5:

Sometimes, while the framework does not support storing models in HDF5 natively, it is possible to do so, e.g.:

noe
  • 28,203
  • 1
  • 49
  • 83