class_docstr: Unit test class for testing scikit-learn converter.
class_docstr_tok: ["Unit","test","class","for","testing","scikit-learn","converter","."]
docstr: Test the conversion for a Embedding + LSTM + Dense layer
docstr_tok: ["Test","the","conversion","for","a","Embedding","+","LSTM","+","Dense","layer"]
code: def test_sentiment_analysis(self):
      """
      Test the conversion for a Embedding + LSTM + Dense layer
      """
      from keras.layers import Dense, Embedding, LSTM
  
      # Create a simple Keras model
      max_features = 50
      embedded_dim = 32
      sequence_length = 10
  
      model = Sequential()
      # Embedding layer example:
      # Embedding(1000, 64, input_length=10) input_dim=index(0~999), 64-dimensional vector, sequence length = 10
      # If we have Dense/Flatten layer upstream, input_length, a.k.a sequence_length is required
  
      model.add(
          Embedding(
              max_features, embedded_dim, input_length=sequence_length
          )
      )
      # output_dim = 32
      model.add(LSTM(32))
      model.add(Dense(1, activation="sigmoid"))
  
      # Input/output
      input_names = ["input"]
      output_names = ["output"]
      spec = keras.convert(model, input_names, output_names).get_spec()
      self.assertIsNotNone(spec)
  
      # Test the model class
      self.assertIsNotNone(spec.description)
      self.assertTrue(spec.HasField("neuralNetwork"))
  
      # Test the inputs and outputs
      # We're giving state input and output so expect description to differ.
      self.assertEquals(
          len(spec.description.input), len(input_names) + 2
      )
      self.assertEquals(
          len(spec.description.output), len(output_names) + 2
      )
  
      # Test the layer parameters.
      layers = spec.neuralNetwork.layers
      self.assertIsNotNone(layers[0].embedding)
      self.assertIsNotNone(layers[1].uniDirectionalLSTM)
      self.assertIsNotNone(layers[2].innerProduct)
  
imports: import unittest
  from coremltools._deps import _HAS_KERAS2_TF
  from coremltools.proto import Model_pb2
  from coremltools.proto import FeatureTypes_pb2
  from coremltools.proto import NeuralNetwork_pb2
  import pytest
label_desc: Use image node_id 19 for calling the KerasSingleLayerTest obj's underlying member method code with example usage: obj.test_sentiment_analysis() without return types