class_docstr: Unit test class for testing scikit-learn converter.
class_docstr_tok: ["Unit","test","class","for","testing","scikit-learn","converter","."]
docstr: Test to ensure that respect_trainable is honored during convert of a
  Keras model defined via the Keras functional API.
docstr_tok: ["Test","to","ensure","that","respect_trainable","is","honored","during","convert","of","a","Keras","model","defined","via","the","Keras","functional","API","."]
code: def test_updatable_model_flag_functional(self):
      """
      Test to ensure that respect_trainable is honored during convert of a
      Keras model defined via the Keras functional API.
      """
      import coremltools
      from keras.layers import Dense, Input
      from keras.losses import categorical_crossentropy
      from keras.optimizers import SGD
  
      input = ["data"]
      output = ["output"]
  
      # This should result in an updatable model.
      inputs = Input(shape=(16,))
      d1 = Dense(128)(inputs)
      d2 = Dense(10, name="foo", activation="softmax", trainable=True)(
          d1
      )
      kmodel = Model(inputs=inputs, outputs=d2)
      kmodel.compile(
          loss=categorical_crossentropy,
          optimizer=SGD(lr=1.0),
          metrics=["accuracy"],
      )
      cml = coremltools.converters.keras.convert(
          kmodel, input, output, respect_trainable=True
      )
      spec = cml.get_spec()
      self.assertTrue(spec.isUpdatable)
      layers = spec.neuralNetwork.layers
      self.assertIsNotNone(layers[1].innerProduct)
      self.assertTrue(layers[1].innerProduct)
      self.assertTrue(layers[1].isUpdatable)
      self.assertEqual(
          len(spec.neuralNetwork.updateParams.lossLayers), 1
      )
      sgdopt = spec.neuralNetwork.updateParams.optimizer.sgdOptimizer
      self.assertEqual(sgdopt.learningRate.defaultValue, 1.0)
      self.assertEqual(sgdopt.miniBatchSize.defaultValue, 16)
      self.assertEqual(sgdopt.momentum.defaultValue, 0.0)
  
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 32 for calling the KerasSingleLayerTest obj's underlying member method code with example usage: obj.test_updatable_model_flag_functional() without return types