Convert a NeurEco Classification model to a Keras model
Convert a NeurEco Classification model to a Keras model#
embed license allows to convert a NeurEco Tabular model to a Keras model.
Note
This feature is only available for the Python API.
This feature requires an existing installation of TensorFlow 2.x and Keras.
Import the NeurEco2Keras library:
from NeurEco import NeurEco2Keras
neureco2keras method of NeurEco2Keras library converts a NeurEco Tabular model to a Keras model.
neureco2keras(neureco_model, keras_model_name=None)
Converts a NeurEco Tabular object to a Keras model
- param neureco_model
NeurEco.NeurEcoTabular: The model to convert
- param keras_model_name
str, optional: name to assign to the created Keras model, default name is “NeurEco_Keras_Model”
- return
Keras model in float32 precision
keras_model = NeurEco2Keras.neureco2keras(neureco_model)
''' print Keras model summary '''
keras_model.summary()
''' evaluate the model using Keras '''
keras_output = keras_model.predict(numpy_input_array.astype("float32"))
Model: "EnergyConsumption_NeurEco_Keras_Model"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
input (InputLayer) [(None, 5)] 0
_________________________________________________________________
tf_op_layer_centeredInputs ( [(None, 5)] 0
_________________________________________________________________
tf_op_layer_normalizedInputs [(None, 5)] 0
_________________________________________________________________
adagos_gemm (AdagosGemm) (None, 8) 48
_________________________________________________________________
tf_op_layer_x1TensorActivati [(None, 8)] 0
_________________________________________________________________
adagos_gemm_1 (AdagosGemm) (None, 1) 9
_________________________________________________________________
tf_op_layer_outputDescaled ( [(None, 1)] 0
_________________________________________________________________
tf_op_layer_output (TensorFl [(None, 1)] 0
=================================================================
Total params: 57
Trainable params: 57
Non-trainable params: 0
_________________________________________________________________
Note
The number of weights in original NeurEco model .ednn is slightly different than the number of trainable parameters in obtained Keras model. This is because the Keras models are intrinsically fully connected, and some of the weights are present in the Keras model although they are not needed (they have a value of 0).
Note
See Tutorial: converting a NeurEco Regression model to a Keras model for a full example of usage.