Icon

05_​Translating_​From_​Keras_​to_​TensorFlow

Translating from a Keras to TensorFlow (Sentiment Analysis)

This first part of this workflow uses the Keras network built to do sentiment analysis on the IMDB data, translates it to a TensorFlow network, and uses the KNIME TensorFlow integration to do predictions. You might want to do this extra step instead of doing the prediction with the Keras because doing prediction with the TensorFlow network is considerably faster than using the Keras network.

The second part of the workflow demonstrates how a TensorFlow network can be loaded from disk and used to make predictions. The saved TensorFlow networks are smaller than Keras models, so this can also be a plus for using the TensorFlow integration.

This example uses the model trained in the workflow 07_Sentiment_Analysis_with_Deep_Learning.

In order to run the example, please make sure you have the following KNIME extensions installed:

* KNIME Deep Learning - TensorFlow Integration (Labs)
* KNIME Deep Learning - Keras Integration (Labs)

You also need a local Python installation that includes Keras and TensorFlow. Please refer to https://www.knime.com/deeplearning#keras for installation recommendations and further information.

Translating from a Keras to TensorFlowThis workflow shows how to train a simple neural network for text classification, in this casesentiment analysis. The used network learns a 128 dimensional word embedding followed byan LSTM. Scoring and Evaluation Save the TensorFlow model Load the TensorFlow model and do predictions Read Keras model and convert to TensorFlow Get all sequencesto same lengthKeras IMDB datapredict testdataRead savedmodelSave as atensorflow file Pad or Truncate Read Data DL Network Executor(deprecated) Scorer ROC Curve Extract Prediction Keras NetworkReader Keras to TensorFlowNetwork Converter TensorFlowNetwork Writer TensorFlowNetwork Reader DL Network Executor(deprecated) ROC Curve Extract Prediction Scorer Translating from a Keras to TensorFlowThis workflow shows how to train a simple neural network for text classification, in this casesentiment analysis. The used network learns a 128 dimensional word embedding followed byan LSTM. Scoring and Evaluation Save the TensorFlow model Load the TensorFlow model and do predictions Read Keras model and convert to TensorFlow Get all sequencesto same lengthKeras IMDB datapredict testdataRead savedmodelSave as atensorflow file Pad or Truncate Read Data DL Network Executor(deprecated) Scorer ROC Curve Extract Prediction Keras NetworkReader Keras to TensorFlowNetwork Converter TensorFlowNetwork Writer TensorFlowNetwork Reader DL Network Executor(deprecated) ROC Curve Extract Prediction Scorer

Nodes

Extensions

Links