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 loss(here cce), conversion is successful
docstr_tok: ["Tests","the","'respect_trainable","'","flag","when","used","along","with","string","for","the","loss","(","here","cce",")",",","conversion","is","successful"]
code: def test_updatable_model_flag_cce_string_sgd(self):
      """
      Tests the 'respect_trainable' flag when used along with string
      for the loss(here cce), conversion is successful
      """
      import coremltools
      from keras.layers import Dense
      from keras.optimizers import SGD
  
      updatable = Sequential()
      updatable.add(Dense(128, input_shape=(16,)))
      updatable.add(
          Dense(10, name="foo", activation="softmax", trainable=True)
      )
      updatable.compile(
          loss="categorical_crossentropy",
          optimizer=SGD(lr=1.0),
          metrics=["accuracy"],
      )
      input = ["data"]
      output = ["output"]
      cml = coremltools.converters.keras.convert(
          updatable, 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
      )
  
      # check that cce input name and output name is set
      # check length is non-zero for cce
      self.assertTrue(
          len(
              spec.neuralNetwork.updateParams.lossLayers[
                  0
              ].categoricalCrossEntropyLossLayer.input
          )
      )
      self.assertTrue(
          len(
              spec.neuralNetwork.updateParams.lossLayers[
                  0
              ].categoricalCrossEntropyLossLayer.target
          )
      )
      # check length is 0 for mse
      self.assertFalse(
          len(
              spec.neuralNetwork.updateParams.lossLayers[
                  0
              ].meanSquaredErrorLossLayer.input
          )
      )
      self.assertFalse(
          len(
              spec.neuralNetwork.updateParams.lossLayers[
                  0
              ].meanSquaredErrorLossLayer.target
          )
      )
  
      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 36 for calling the KerasSingleLayerTest obj's underlying member method code with example usage: obj.test_updatable_model_flag_cce_string_sgd() without return types