Interface Parameters

All Superinterfaces:
Serializable
All Known Subinterfaces:
FeedForwardParameters
All Known Implementing Classes:
CRFParameters, FMParameters, LinearParameters

public interface Parameters extends Serializable
An interface to a Tensor[] array which accepts updates to the parameters.

Parameters is essentially an SGD model at training time.

Subclasses of this can add methods for calculating gradients for their prediction task, or use an external objective class.

Implementations must be serializable.

  • Method Summary

    Modifier and Type
    Method
    Description
    get()
    Get a reference to the underlying Tensor array.
    Generates an empty copy of the underlying Tensor array.
    merge(Tensor[][] gradients, int size)
    Merge together an array of gradient arrays.
    void
    set(Tensor[] newWeights)
    Set the underlying Tensor array to newWeights.
    void
    update(Tensor[] gradients)
    Apply gradients to the parameters.
  • Method Details

    • getEmptyCopy

      Tensor[] getEmptyCopy()
      Generates an empty copy of the underlying Tensor array.

      It's the same size and shape as the parameters, but all the values are 0.0.

      Returns:
      A copy of the parameters where all values are 0.0.
    • get

      Tensor[] get()
      Get a reference to the underlying Tensor array.
      Returns:
      The parameters.
    • set

      void set(Tensor[] newWeights)
      Set the underlying Tensor array to newWeights.
      Parameters:
      newWeights - New parameters to store in this object.
    • update

      void update(Tensor[] gradients)
      Apply gradients to the parameters. Assumes that gradients is the same length as the parameters, and each Tensor is the same size as the corresponding one from the parameters.

      The gradients are added to the parameters.

      Parameters:
      gradients - A Tensor array of updates, with the length equal to get().length.
    • merge

      Tensor[] merge(Tensor[][] gradients, int size)
      Merge together an array of gradient arrays. Assumes the first dimension is the number of gradient arrays and the second dimension is the number of parameter Tensors.

      For performance reasons this call may mutate the input gradient array, and may return a subset of those elements as the merge output.

      Parameters:
      gradients - An array of gradient update arrays.
      size - The number of elements of gradients to merge. Allows gradients to have unused elements.
      Returns:
      A single Tensor array of the summed gradients.