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 Dense + Activation('something')
docstr_tok: ["Test","the","conversion","for","a","Dense","+","Activation","(","'something","'",")"]
code: def test_activations(self):
      """
      Test the conversion for a Dense + Activation('something')
      """
      from keras.layers import Dense, Activation
  
      # Create a simple Keras model
      keras_activation_options = [
          "elu",
          "tanh",
          "softplus",
          "softsign",
          "relu",
          "sigmoid",
          "hard_sigmoid",
          "linear",
      ]
      coreml_activation_options = [
          "ELU",
          "tanh",
          "softplus",
          "softsign",
          "ReLU",
          "sigmoid",
          "sigmoidHard",
          "linear",
      ]
  
      for i, k_act in enumerate(keras_activation_options):
          c_act = coreml_activation_options[i]
          model = Sequential()
          model.add(Dense(32, input_dim=16))
          model.add(Activation(k_act))
  
          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
          self.assertEquals(
              len(spec.description.input), len(input_names)
          )
          self.assertEqual(
              sorted(input_names),
              sorted(map(lambda x: x.name, spec.description.input)),
          )
          self.assertEquals(
              len(spec.description.output), len(output_names)
          )
          self.assertEqual(
              sorted(output_names),
              sorted(map(lambda x: x.name, spec.description.output)),
          )
  
          # Test the layer parameters.
          layers = spec.neuralNetwork.layers
          self.assertIsNotNone(layers[0].innerProduct)
          self.assertIsNotNone(layers[1].activation)
          self.assertTrue(layers[1].activation.HasField(c_act))
  
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 3 for calling the KerasSingleLayerTest obj's underlying member method code with example usage: obj.test_activations() without return types