class_docstr: A trained model that is ready to use for sound classification or to export to CoreML.
  
  This model should not be constructed directly.
  
  See Also
  ----------
  create
class_docstr_tok: ["A","trained","model","that","is","ready","to","use","for","sound","classification","or","to","export","to","CoreML",".","This","model","should","not","be","constructed","directly",".","See","Also","--","--","--","--","--","create"]
docstr: Save the model in Core ML format.
  
  See Also
  --------
  save
  
  Examples
  --------
  >>> model.export_coreml('./myModel.mlmodel')
docstr_tok: ["Save","the","model","in","Core","ML","format",".","See","Also","--","--","--","--","save","Examples","--","--","--","--",">",">",">","model.export_coreml","(","'.\/myModel.mlmodel","'",")"]
code: def export_coreml(self, filename):
      """
      Save the model in Core ML format.
  
      See Also
      --------
      save
  
      Examples
      --------
      >>> model.export_coreml('./myModel.mlmodel')
      """
      coremltools = _minimal_package_import_check("coremltools")
      from coremltools.proto.FeatureTypes_pb2 import ArrayFeatureType
  
      prob_name = self.target + "Probability"
  
      def get_custom_model_spec():
          from coremltools.models.neural_network import (
              NeuralNetworkBuilder,
          )
          from coremltools.models.datatypes import Array
  
          input_name = "output1"
          input_length = self._feature_extractor.output_length
          builder = NeuralNetworkBuilder(
              [
                  (
                      input_name,
                      Array(
                          input_length,
                      ),
                  )
              ],
              [
                  (
                      prob_name,
                      Array(
                          self.num_classes,
                      ),
                  )
              ],
              "classifier",
          )
          layer_counter = [0]
          builder.set_input([input_name], [(input_length,)])
  
          def next_layer_name():
              layer_counter[0] += 1
              return "layer_%d" % layer_counter[0]
  
          for i, cur_layer in enumerate(
              self._custom_classifier.export_weights()
          ):
              W = cur_layer["weight"]
              nC, nB = W.shape
              Wb = cur_layer["bias"]
  
              output_name = next_layer_name()
              builder.add_inner_product(
                  name="inner_product_" + str(i),
                  W=W,
                  b=Wb,
                  input_channels=nB,
                  output_channels=nC,
                  has_bias=True,
                  input_name=input_name,
                  output_name=output_name,
              )
  
              input_name = output_name
  
              if cur_layer["act"]:
                  output_name = next_layer_name()
                  builder.add_activation(
                      "activation" + str(i),
                      "RELU",
                      input_name,
                      output_name,
                  )
                  input_name = output_name
  
          builder.add_softmax("softmax", input_name, prob_name)
          builder.set_class_labels(
              self.classes,
              predicted_feature_name=self.target,
              prediction_blob=prob_name,
          )
          return builder.spec
  
      top_level_spec = coremltools.proto.Model_pb2.Model()
      top_level_spec.specificationVersion = 3
  
      # Set input
      desc = top_level_spec.description
      input = desc.input.add()
      input.name = self.feature
      assert type(self.feature) is str
      input.type.multiArrayType.dataType = (
          ArrayFeatureType.ArrayDataType.Value("FLOAT32")
      )
      input.type.multiArrayType.shape.append(15600)
  
      # Set outputs
      prob_output = desc.output.add()
      prob_output.name = prob_name
      label_output = desc.output.add()
      label_output.name = self.target
      desc.predictedFeatureName = self.target
      desc.predictedProbabilitiesName = prob_name
      if type(self.classes[0]) == int:
          # Class labels are ints
          prob_output.type.dictionaryType.int64KeyType.MergeFromString(
              b""
          )
          label_output.type.int64Type.MergeFromString(b"")
      else:  # Class are strings
          prob_output.type.dictionaryType.stringKeyType.MergeFromString(
              b""
          )
          label_output.type.stringType.MergeFromString(b"")
  
      # Set metadata
      user_metadata = desc.metadata.userDefined
      user_metadata["sampleRate"] = str(
          self._feature_extractor.input_sample_rate
      )
  
      pipeline = top_level_spec.pipelineClassifier.pipeline
  
      # Add the preprocessing model
      preprocessing_model = pipeline.models.add()
      preprocessing_model.customModel.className = (
          "TCSoundClassifierPreprocessing"
      )
      preprocessing_model.specificationVersion = 3
      preprocessing_input = preprocessing_model.description.input.add()
      preprocessing_input.CopyFrom(input)
  
      preprocessed_output = preprocessing_model.description.output.add()
      preprocessed_output.name = "preprocessed_data"
      preprocessed_output.type.multiArrayType.dataType = (
          ArrayFeatureType.ArrayDataType.Value("DOUBLE")
      )
      preprocessed_output.type.multiArrayType.shape.append(1)
      preprocessed_output.type.multiArrayType.shape.append(96)
      preprocessed_output.type.multiArrayType.shape.append(64)
  
      # Add the feature extractor, updating its input name
      feature_extractor_spec = self._feature_extractor.get_spec()
      pipeline.models.add().CopyFrom(feature_extractor_spec)
      pipeline.models[-1].description.input[
          0
      ].name = preprocessed_output.name
      pipeline.models[-1].neuralNetwork.layers[0].input[
          0
      ] = preprocessed_output.name
  
      # Add the custom neural network
      pipeline.models.add().CopyFrom(get_custom_model_spec())
  
      # Set key type for the probability dictionary
      prob_output_type = (
          pipeline.models[-1].description.output[0].type.dictionaryType
      )
      if type(self.classes[0]) == int:
          prob_output_type.int64KeyType.MergeFromString(b"")
      else:  # String labels
          prob_output_type.stringKeyType.MergeFromString(b"")
  
      mlmodel = coremltools.models.MLModel(top_level_spec)
      model_type = "sound classifier"
      mlmodel.short_description = (
          _coreml_utils._mlmodel_short_description(model_type)
      )
      mlmodel.input_description[self.feature] = "Input audio features"
      mlmodel.output_description[prob_name] = "Prediction probabilities"
      mlmodel.output_description[
          self.target
      ] = "Class label of top prediction"
      model_metadata = {
          "target": self.target,
          "feature": self.feature,
      }
      user_defined_metadata = model_metadata.update(
          _coreml_utils._get_tc_version_info()
      )
      _coreml_utils._set_model_metadata(
          mlmodel,
          self.__class__.__name__,
          user_defined_metadata,
          version=SoundClassifier._PYTHON_SOUND_CLASSIFIER_VERSION,
      )
      mlmodel.save(filename)
  
imports: from __future__ import print_function
  from __future__ import division
  from __future__ import absolute_import
  import logging
  from math import ceil
  import numpy
  import six
  import turicreate
  import turicreate.toolkits._internal_utils
  from turicreate.toolkits._main import ToolkitError
  from turicreate.toolkits._model import CustomModel
  from turicreate.toolkits._model import PythonProxy
  from turicreate.toolkits import _coreml_utils
  from turicreate._deps.minimal_package import _minimal_package_import_check
label_desc: Use image node_id 11 for calling the SoundClassifier obj's underlying member method code with example usage: obj.export_coreml(filename) and returns: builder, unknown