Attaching custom data to H2O model and save it to disk, then load it back

I just trained a Neural Network with H2O as follows:

> m = h2o.deeplearning(
  model_id = "nn_testing",
  ...
)

Then, I want to save it to disk, but before that I want save along with it some context information, for example: { room: "C", approved: "Yes" }

I tried the following:

> m@room = "C"

But I got the error:

Error in (function (cl, name, valueClass)  : 
  ‘room’ is not a slot in class “H2OBinomialModel”

Then I tried something I found here:

https://www.rdocumentation.org/packages/methods/versions/3.6.1/topics/setClass

by doing:

> H2OBinomialModelCustom = setClass(
  "H2OBinomialModelCustom",
  slots = c(room = "character", approved = "character"),
  contains = "H2OBinomialModel"
)
> m2 = H2OBinomialModelCustom(m, room = "C", approved = "Yes")
> View(m2)

and I got the following:

image

which looks promising.

Then I save it to the current directory:

> h2o.saveModel(m2, ".")

Then I load it back and save it on variable: m3:

> m3 = h2o.loadModel(path = "./nn_testing")
> View(m3)

image

but unfortunately, as you can see above, those 2 attributes are not there.

It looks like they were not saved when I did: h2o.saveModel(...).

Any idea on how can I save custom info along H2O Neural Networks? I think this is a common use case since some times is very important to save information relative to the context of the training.

Thanks!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.