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 of 2D convolutional layer + upsample
docstr_tok: ["Test","the","conversion","of","2D","convolutional","layer","+","upsample"]
code: def test_upsample(self):
      """
      Test the conversion of 2D convolutional layer + upsample
      """
      from keras.layers import Conv2D, UpSampling2D
  
      # Create a simple Keras model
      model = Sequential()
      model.add(
          Conv2D(
              input_shape=(64, 64, 3), filters=32, kernel_size=(5, 5)
          )
      )
      model.add(UpSampling2D(size=(2, 2)))
      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
      layer_0 = layers[0]
      self.assertIsNotNone(layer_0.convolution)
      layer_1 = layers[1]
      self.assertIsNotNone(layer_1.upsample)
      self.assertEquals(
          layer_1.upsample.mode,
          NeuralNetwork_pb2.UpsampleLayerParams.InterpolationMode.Value(
              "NN"
          ),
      )
  
      # Test if BILINEAR mode works as well
      model = Sequential()
      model.add(
          Conv2D(
              input_shape=(64, 64, 3), filters=32, kernel_size=(5, 5)
          )
      )
      try:
          model.add(UpSampling2D(size=(2, 2), interpolation="bilinear"))
      except (
          TypeError
      ):  # Early version of Keras, no support for 'interpolation'
          return
  
      spec = keras.convert(model, input_names, output_names).get_spec()
      self.assertIsNotNone(spec)
      layers = spec.neuralNetwork.layers
      layer_1 = layers[1]
      self.assertIsNotNone(layer_1.upsample)
      self.assertEquals(
          layer_1.upsample.mode,
          NeuralNetwork_pb2.UpsampleLayerParams.InterpolationMode.Value(
              "BILINEAR"
          ),
      )
  
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 11 for calling the KerasSingleLayerTest obj's underlying member method code with example usage: obj.test_upsample() without return types