Skip to content

Commit

Permalink
Merge pull request #48 from MaxTuecke/keras_documentation
Browse files Browse the repository at this point in the history
Added documentation to custom_keras_objects
  • Loading branch information
WardLT committed Mar 4, 2019
2 parents 327303b + 6f564d3 commit 7f7404b
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion docs/servable-types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,30 @@ can be created from this model file and names for the output classes:

.. code-block:: python
model info = KerasModel.create_model('model.h5', ["y"])
model_info = KerasModel.create_model('model.h5', ["y"])
Models with weights and architecture as separate files can be described using:

.. code-block:: python
model_info = KerasModel.create_model('model.h5', ["y"], arch_path='arch.json')
Keras also allows users to add their own custom layers to their models for any custom operation
that has trainable weights. Use this when the Keras Lambda layer does not apply. In Keras,
these layers can be added when loading the model:

.. code-block:: python
model = load_model('model.h5', custom_objects={'CustomLayer': CustomLayer})
Adding custom layers to a DLHub description can be achived with the ``add_custom_object`` method, which takes the name
and class of the custom layer:

.. code-block:: python
model_info.add_custom_object('CustomLayer', CustomLayer)
See more info on creating custom Keras layers `here <https://keras.io/layers/writing-your-own-keras-layers/>`_.

The DLHub SDK reads the architecture in the HDF5 file and determines the inputs
and outputs automatically:
Expand Down

0 comments on commit 7f7404b

Please sign in to comment.