I’m building a feedforward model with DL4J extension. Once my model is trained I would like to migrate it to an external tool (I need a C implementation). Basically, I would like to access to a visualization, or get the values of my parameters.
I tried Model Writer and DL4J Model Writer nodes, but it seems to give me files readable only by knime.
Thanks in advance and sorry for my English.
unfortunately DL4J saves their models in their own format. As far as I know, there is no easy way to convert the format. Where would you like to use the model? Could be switching to Keras an option? Depending on the external tool, I would say that the chances are higher that there is a converter for Keras than for DL4J.
Thanks for your answer. My purpose is to use Knime to train my neural network. I will implement it later in a C program. I was hoping for a PMML solution or at least retrieve my weight and biais matrix.
I’ll probably switch to Kerasn then.
the file written by the DL4J Model Writer is just a .zip. You can extract it and look at the contents. There should be some weights file in the ND4J format. For Keras it is similar. The model will be saved to a single .h5 file (see https://keras.io/getting-started/faq/#how-can-i-save-a-keras-model).
Maybe you can find a specification how the weights are actually saved (order, structure of the file).
Regarding PMML I found the following: https://github.com/vaclavcadek/keras2pmml.
If I’m not wrong the file written by DL4J Model Writer is just a big HexaDecimal file.
Model Writer creates a zip containing the same HexaDecimal file called “object.file”, another HexaDecimal file signicantly smaller called “objectSpec.file”. There is a last file content.xml content.xml (524 Bytes)
This XML seems to be a standard file. And I tried to convert both HexaDecimal files but it doesn’t help.
The DL4J Model Writer always outputs a .zip file (although it may not have that ending). You can just unzip it to any folder. It contains a bunch of config files created by KNIME and one file named
mln_model, which is the model written by DL4J. This is in turn another .zip file containing the model config (layers, params, etc.) and a
coefficients.bin file. This one contains the weights in binary format. To find out about the actual specification of the
.bin file you would have to do some research on the DL4J/ND4J websites (ND4J is the matrix library DL4J is using).
Hum okay, make sense now. I was lost with the extensions about which file was a .zip or not.
That’s really helpful, I’ll do some researches on DL4J/ND4J.
I’ll give you a feedback if I manage to do something.