Class

MLParameterKey

The keys for the parameter dictionary in a model configuration or a model update context.

Declaration

@interface MLParameterKey : MLKey

Overview

Use an MLParameterKey to retrieve a model’s parameter value using:

Overriding Model and Layer Parameters

To override a model’s default parameter values:

  1. Create an MLModelConfiguration instance.

  2. Use an MLParameterKey for each parameter to set its value in the model configuration’s parameters dictionary.

  3. Create a new model instance using modelWithContentsOfURL:configuration:error: with your custom model configuration.

Configuring Update Parameters

To configure the update parameters for an MLUpdateTask:

  1. Create an MLModelConfiguration instance.

  2. Use an MLParameterKey for each parameter to set its value in the model configuration’s parameters dictionary.

  3. Create a new update task with your custom model configuration.

See Personalizing a Model with On-Device Updates.

Topics

Scoping Parameter Keys

- scopedTo:

Creates a copy of a parameter key and adds the scope to it.

Accessing Model Parameters

numberOfNeighbors

The key you use to access the number of neighbors that adjusts the affinity of a k-nearest-neighbor model.

linkedModelFileName

The key you use to access the linked model’s filename.

linkedModelSearchPath

The key you use to access the linked model’s search path.

Accessing Neural Network Layer Parameters

weights

The key you use to access the weights of a layer in a neural network model.

biases

The key you use to access the biases of a layer in a neural network model.

Accessing Model Update Parameters

learningRate

The key you use to access the optimizer’s learning rate parameter.

momentum

The key you use to access the stochastic gradient descent (SGD) optimizer’s momentum parameter.

miniBatchSize

The key you use to access the optimizer’s mini batch-size parameter.

beta1

The key you use to access the Adam optimizer’s first beta parameter.

beta2

The key you use to access the Adam optimizer’s second beta parameter.

eps

The key you use to access the Adam optimizer’s epsilon parameter.

epochs

The key you use to access the optimizer’s epochs parameter.

shuffle

The key you use to access the shuffle parameter, a Boolean value that determines whether the model randomizes the data between epochs.

seed

The key you use to access the seed parameter that initializes the random number generator for the shuffle option.

Relationships

Inherits From

See Also

Inspecting a Model

configuration

The configuration of the model set during initialization.

modelDescription

Model information you use at runtime during development, which Xcode also displays in its Core ML model editor view.

MLModelDescription

Information about a model, primarily the input and output format for each feature the model expects, and optional metadata.

- parameterValueForKey:error:

Returns a model parameter value for a key.

MLKey

An abstract base class for machine learning key types.