class_docstr: Unit test class for testing scikit-learn converter.
class_docstr_tok: ["Unit","test","class","for","testing","scikit-learn","converter","."]
docstr: Tests the 'respect_trainable' flag when used along with string
  for the optimizer(keras internally creates an instance, here adam),
  conversion is successful
docstr_tok: ["Tests","the","'respect_trainable","'","flag","when","used","along","with","string","for","the","optimizer","(","keras","internally","creates","an","instance",",","here","adam",")",",","conversion","is","successful"]
code: def test_updatable_model_flag_cce_adam_string(self):
      """
      Tests the 'respect_trainable' flag when used along with string
      for the optimizer(keras internally creates an instance, here adam),
      conversion is successful
      """
      import coremltools
      from keras.layers import Dense, Input
      from keras.losses import categorical_crossentropy
  
      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="adam",
          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
      )
      adopt = spec.neuralNetwork.updateParams.optimizer.adamOptimizer
      # use almost equal for default verification with at least 5 decimal
      # places of closeness
      self.assertAlmostEqual(
          adopt.learningRate.defaultValue, 0.001, places=5
      )
      self.assertAlmostEqual(adopt.miniBatchSize.defaultValue, 16)
      self.assertAlmostEqual(adopt.beta1.defaultValue, 0.90, places=5)
      self.assertAlmostEqual(adopt.beta2.defaultValue, 0.999, places=5)
  
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 38 for calling the KerasSingleLayerTest obj's underlying member method code with example usage: obj.test_updatable_model_flag_cce_adam_string() without return types