Search Results for

    Show / Hide Table of Contents

    Struct WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.MultiRepresentationWeightFunction<TDictionary>

    An implementation of WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.IWeightFunction<TThis> that automatically chooses between WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.PointMassWeightFunction, WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.DictionaryWeightFunction<TThis>, and Automaton<TSequence, TElement, TElementDistribution, TSequenceManipulator, TThis> representation.

    Implements
    WeightFunctions.IWeightFunction<WeightFunctions.MultiRepresentationWeightFunction<TDictionary>>
    WeightFunctions.IWeightFunction<>
    IEquatable<WeightFunctions.MultiRepresentationWeightFunction<TDictionary>>
    Inherited Members
    Object.Equals(Object, Object)
    Object.GetType()
    Object.ReferenceEquals(Object, Object)
    Namespace: Microsoft.ML.Probabilistic.Distributions.Automata
    Assembly: Microsoft.ML.Probabilistic.dll
    Syntax
    [Serializable]
    [DataContract]
    [Quality(QualityBand.Experimental)]
    public readonly struct MultiRepresentationWeightFunction<TDictionary> : WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.IWeightFunction<WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.MultiRepresentationWeightFunction<TDictionary>>, WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.IWeightFunction, IEquatable<WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.MultiRepresentationWeightFunction<TDictionary>> where TDictionary : WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.DictionaryWeightFunction<TDictionary>, new()
    Type Parameters
    Name Description
    TDictionary

    The type used for weight functions represented as dictionaries.

    Properties

    IsAutomaton

    Gets a value indicating whether the weight function uses an automaton internal representation.

    Declaration
    public readonly bool IsAutomaton { get; }
    Property Value
    Type Description
    Boolean

    IsDictionary

    Gets a value indicating whether the weight function uses a dictionary internal representation.

    Declaration
    public readonly bool IsDictionary { get; }
    Property Value
    Type Description
    Boolean

    IsPointMass

    Gets a value indicating whether the current weight function assigns a non-zero weight to exactly one point.

    Declaration
    public readonly bool IsPointMass { get; }
    Property Value
    Type Description
    Boolean

    Point

    Gets the only point to which the current function assigns a non-zero weight.

    Declaration
    public readonly TSequence Point { get; }
    Property Value
    Type Description
    TSequence
    Exceptions
    Type Condition
    InvalidOperationException

    Thrown when an attempt is made to get the Point of a non-pointmass weight function.

    UsesAutomatonRepresentation

    Gets a value indicating whether the current weight function is represented as an automaton internally.

    Declaration
    public readonly bool UsesAutomatonRepresentation { get; }
    Property Value
    Type Description
    Boolean

    UsesGroups

    Checks if the weight function uses groups.

    Declaration
    public readonly bool UsesGroups { get; }
    Property Value
    Type Description
    Boolean

    true if the weight function uses groups, false otherwise.

    Methods

    Append(TSequence, Int32)

    Creates a weight function f'(st) = f(s), where f(s) is the current weight function and t is the given sequence.

    Declaration
    public readonly WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.MultiRepresentationWeightFunction<TDictionary> Append(TSequence sequence, int group = 0)
    Parameters
    Type Name Description
    TSequence sequence

    The sequence.

    Int32 group

    The group.

    Returns
    Type Description
    WeightFunctions.MultiRepresentationWeightFunction<TDictionary>

    The created weight function.

    Append(WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.MultiRepresentationWeightFunction<TDictionary>, Int32)

    Creates a weight function f'(s) = sum_{tu=s} f(t)g(u), where f(t) is the current weight function and g(u) is the given weight function.

    Declaration
    public readonly WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.MultiRepresentationWeightFunction<TDictionary> Append(WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.MultiRepresentationWeightFunction<TDictionary> weightFunction, int group = 0)
    Parameters
    Type Name Description
    WeightFunctions.MultiRepresentationWeightFunction<TDictionary> weightFunction
    Int32 group

    The group.

    Returns
    Type Description
    WeightFunctions.MultiRepresentationWeightFunction<TDictionary>

    The created weight function.

    AsAutomaton()

    Returns an automaton representation of the current weight function. If the weight function is normalized, the resulting automaton is stochastic, i.e. the sum of weights of all the outgoing transitions and the ending weight is 1 for every node.

    Declaration
    public readonly TAutomaton AsAutomaton()
    Returns
    Type Description
    TAutomaton

    AsDictionary()

    Returns a dictionary representation of the current weight function, if it is being used, or null otherwise.

    Declaration
    public readonly TDictionary AsDictionary()
    Returns
    Type Description
    TDictionary

    AsPointMass()

    Returns a point mass representation of the current weight function, if it is being used, or null otherwise.

    Declaration
    public readonly WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.PointMassWeightFunction AsPointMass()
    Returns
    Type Description
    WeightFunctions.PointMassWeightFunction<>

    EnumeratePaths()

    Enumerates paths through this weight function.

    Declaration
    public readonly IEnumerable<Tuple<List<TElementDistribution>, double>> EnumeratePaths()
    Returns
    Type Description
    IEnumerable<Tuple<List<TElementDistribution>, Double>>

    The paths through this weight function, with their log weights

    EnumerateSupport(Int32)

    Enumerates support of this weight function when possible.

    Declaration
    public readonly IEnumerable<TSequence> EnumerateSupport(int maxCount = 1000000)
    Parameters
    Type Name Description
    Int32 maxCount

    The maximum support enumeration count.

    Returns
    Type Description
    IEnumerable<TSequence>

    The sequences in the support of this weight function

    Exceptions
    Type Condition
    AutomatonEnumerationCountException

    Thrown if enumeration is too large.

    Equals(WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.MultiRepresentationWeightFunction<TDictionary>)

    Declaration
    public readonly bool Equals(WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.MultiRepresentationWeightFunction<TDictionary> other)
    Parameters
    Type Name Description
    WeightFunctions.MultiRepresentationWeightFunction<TDictionary> other
    Returns
    Type Description
    Boolean

    Equals(Object)

    Declaration
    public override readonly bool Equals(object obj)
    Parameters
    Type Name Description
    Object obj
    Returns
    Type Description
    Boolean
    Overrides
    ValueType.Equals(Object)

    FromAutomaton(TAutomaton)

    Creates a WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.MultiRepresentationWeightFunction<TDictionary> represented as Automaton<TSequence, TElement, TElementDistribution, TSequenceManipulator, TThis>.

    Declaration
    [Construction(new string[]{"AsAutomaton"}, UseWhen = "IsAutomaton")]
    public static WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.MultiRepresentationWeightFunction<TDictionary> FromAutomaton(TAutomaton automaton)
    Parameters
    Type Name Description
    TAutomaton automaton

    The automaton.

    Returns
    Type Description
    WeightFunctions.MultiRepresentationWeightFunction<TDictionary>

    The created weight function.

    FromDictionary(TDictionary)

    Creates a WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.MultiRepresentationWeightFunction<TDictionary> represented as WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.DictionaryWeightFunction<TThis>.

    Declaration
    [Construction(new string[]{"AsDictionary"}, UseWhen = "IsDictionary")]
    public static WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.MultiRepresentationWeightFunction<TDictionary> FromDictionary(TDictionary dictionary)
    Parameters
    Type Name Description
    TDictionary dictionary

    The dictionary weight function.

    Returns
    Type Description
    WeightFunctions.MultiRepresentationWeightFunction<TDictionary>

    The created weight function.

    FromPoint(TSequence)

    Creates a point mass weight function.

    Declaration
    public static WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.MultiRepresentationWeightFunction<TDictionary> FromPoint(TSequence point)
    Parameters
    Type Name Description
    TSequence point

    The point.

    Returns
    Type Description
    WeightFunctions.MultiRepresentationWeightFunction<TDictionary>

    The created point mass weight function.

    FromPointMass(WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.PointMassWeightFunction)

    Creates a WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.MultiRepresentationWeightFunction<TDictionary> represented as WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.PointMassWeightFunction.

    Declaration
    [Construction(new string[]{"AsPointMass"}, UseWhen = "IsPointMass")]
    public static WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.MultiRepresentationWeightFunction<TDictionary> FromPointMass(WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.PointMassWeightFunction pointMass)
    Parameters
    Type Name Description
    WeightFunctions.PointMassWeightFunction<> pointMass

    The point mass weight function.

    Returns
    Type Description
    WeightFunctions.MultiRepresentationWeightFunction<TDictionary>

    The created weight function.

    GetGroups()

    If the current weight function uses groups, returns a dictionary [group index] -> group. Otherwise, returns an empty dictionary.

    Declaration
    public readonly Dictionary<int, WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.MultiRepresentationWeightFunction<TDictionary>> GetGroups()
    Returns
    Type Description
    Dictionary<Int32, WeightFunctions.MultiRepresentationWeightFunction<TDictionary>>

    A possibly empty dictionary [group index] -> group.

    GetHashCode()

    Declaration
    public override readonly int GetHashCode()
    Returns
    Type Description
    Int32
    Overrides
    ValueType.GetHashCode()

    GetLogNormalizer()

    Computes the logarithm of the normalizer (sum of values of the weight function on all sequences).

    Declaration
    public readonly double GetLogNormalizer()
    Returns
    Type Description
    Double

    The logarithm of the normalizer.

    Remarks

    Returns PositiveInfinity if the sum diverges.

    GetLogValue(TSequence)

    Computes the logarithm of the value of the weight function on a given sequence.

    Declaration
    public readonly double GetLogValue(TSequence sequence)
    Parameters
    Type Name Description
    TSequence sequence

    The sequence to compute the value on.

    Returns
    Type Description
    Double

    The logarithm of the value.

    HasGroup(Int32)

    Determines whether this weight function has the specified group (if applicable).

    Declaration
    public readonly bool HasGroup(int group)
    Parameters
    Type Name Description
    Int32 group

    The specified group.

    Returns
    Type Description
    Boolean

    True if it the weight function has this group, false otherwise.

    IsCanonicZero()

    Checks whether the weight function is a canonic representation of zero, as produced by Zero().

    Declaration
    public readonly bool IsCanonicZero()
    Returns
    Type Description
    Boolean

    true if the weight function is a canonic representation of zero, false otherwise.

    Remarks

    The time complexity of this function is O(1), so it can be used to treat zero specially in performance-critical code. All the operations on automata resulting in zero produce the canonic representation.

    IsZero()

    Checks whether the current weight function is zero on all sequences.

    Declaration
    public readonly bool IsZero()
    Returns
    Type Description
    Boolean

    true if the current weight function is zero on all sequences, false otherwise.

    MaxDiff(WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.MultiRepresentationWeightFunction<TDictionary>)

    Gets a value indicating how close this weight function is to a given one in terms of weights they assign to sequences.

    Declaration
    public readonly double MaxDiff(WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.MultiRepresentationWeightFunction<TDictionary> that)
    Parameters
    Type Name Description
    WeightFunctions.MultiRepresentationWeightFunction<TDictionary> that
    Returns
    Type Description
    Double

    A non-negative value, which is close to zero if the two weight functions assign similar values to all sequences.

    NormalizeStructure()

    Returns the weight function converted to the normalized form e.g. using special case structures for point masses and functions with small support.

    Declaration
    public readonly WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.MultiRepresentationWeightFunction<TDictionary> NormalizeStructure()
    Returns
    Type Description
    WeightFunctions.MultiRepresentationWeightFunction<TDictionary>

    Product(WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.MultiRepresentationWeightFunction<TDictionary>)

    Computes the product of the current weight function and a given one.

    Declaration
    public readonly WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.MultiRepresentationWeightFunction<TDictionary> Product(WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.MultiRepresentationWeightFunction<TDictionary> weightFunction)
    Parameters
    Type Name Description
    WeightFunctions.MultiRepresentationWeightFunction<TDictionary> weightFunction
    Returns
    Type Description
    WeightFunctions.MultiRepresentationWeightFunction<TDictionary>

    The computed product.

    Repeat(Int32, Nullable<Int32>)

    Creates a weight function g(s) = sum_{k=Kmin}^{Kmax} sum_{t1 t2 ... tk = s} f(t1)f(t2)...f(tk), where f(t) is the current weight function, and Kmin and Kmax are the minimum and the maximum number of factors in a sum term.

    Declaration
    public readonly WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.MultiRepresentationWeightFunction<TDictionary> Repeat(int minTimes = 1, int? maxTimes = null)
    Parameters
    Type Name Description
    Int32 minTimes

    The minimum number of factors in a sum term. Defaults to 1.

    Nullable<Int32> maxTimes

    An optional maximum number of factors in a sum term.

    Returns
    Type Description
    WeightFunctions.MultiRepresentationWeightFunction<TDictionary>

    The created weight function.

    ScaleLog(Double)

    Scales the weight function and returns the result.

    Declaration
    public readonly WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.MultiRepresentationWeightFunction<TDictionary> ScaleLog(double logScale)
    Parameters
    Type Name Description
    Double logScale

    The logarithm of the scale.

    Returns
    Type Description
    WeightFunctions.MultiRepresentationWeightFunction<TDictionary>

    The scaled weight function.

    Sum(WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.MultiRepresentationWeightFunction<TDictionary>)

    Computes the sum of the current weight function and a given weight function.

    Declaration
    public readonly WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.MultiRepresentationWeightFunction<TDictionary> Sum(WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.MultiRepresentationWeightFunction<TDictionary> weightFunction)
    Parameters
    Type Name Description
    WeightFunctions.MultiRepresentationWeightFunction<TDictionary> weightFunction
    Returns
    Type Description
    WeightFunctions.MultiRepresentationWeightFunction<TDictionary>

    The computed sum.

    Sum(Double, WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.MultiRepresentationWeightFunction<TDictionary>, Double)

    Computes the weighted sum of the current weight function and a given weight function.

    Declaration
    public readonly WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.MultiRepresentationWeightFunction<TDictionary> Sum(double weight1, WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.MultiRepresentationWeightFunction<TDictionary> weightFunction, double weight2)
    Parameters
    Type Name Description
    Double weight1

    The weight of the current weight function.

    WeightFunctions.MultiRepresentationWeightFunction<TDictionary> weightFunction
    Double weight2

    The weight of the weightFunction.

    Returns
    Type Description
    WeightFunctions.MultiRepresentationWeightFunction<TDictionary>

    SumLog(Double, WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.MultiRepresentationWeightFunction<TDictionary>, Double)

    Computes the weighted sum of the current weight function and a given weight function.

    Declaration
    public readonly WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.MultiRepresentationWeightFunction<TDictionary> SumLog(double logWeight1, WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.MultiRepresentationWeightFunction<TDictionary> weightFunction, double logWeight2)
    Parameters
    Type Name Description
    Double logWeight1

    The logarithm of the weight of the current weight function.

    WeightFunctions.MultiRepresentationWeightFunction<TDictionary> weightFunction
    Double logWeight2

    The logarithm of the weight of the weightFunction.

    Returns
    Type Description
    WeightFunctions.MultiRepresentationWeightFunction<TDictionary>

    ToString()

    Declaration
    public override readonly string ToString()
    Returns
    Type Description
    String
    Overrides
    ValueType.ToString()

    ToString(Action<TElementDistribution, StringBuilder>)

    Returns a string that represents the weight function.

    Declaration
    public readonly string ToString(Action<TElementDistribution, StringBuilder> appendElement)
    Parameters
    Type Name Description
    Action<TElementDistribution, StringBuilder> appendElement

    Optional method for appending at the element distribution level.

    Returns
    Type Description
    String

    A string that represents the weight function.

    TryEnumerateSupport(Int32, out IEnumerable<TSequence>)

    Tries to enumerate support of this weight function.

    Declaration
    public readonly bool TryEnumerateSupport(int maxCount, out IEnumerable<TSequence> result)
    Parameters
    Type Name Description
    Int32 maxCount

    The maximum support enumeration count.

    IEnumerable<TSequence> result

    The sequences in the support of this weight function

    Returns
    Type Description
    Boolean

    True if successful, false otherwise

    TryNormalizeValues(out WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.MultiRepresentationWeightFunction<TDictionary>, out Double)

    Attempts to normalize the weight function so that sum of its values on all possible sequences equals to one (if it is possible) and returns the result in an out parameter. If successful, calls to AsAutomaton() methods of the resulting function produce a stochastic automaton, i.e. an automaton, in which the sum of weights of all the outgoing transitions and the ending weight is 1 for every node.

    Declaration
    public readonly bool TryNormalizeValues(out WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.MultiRepresentationWeightFunction<TDictionary> normalizedFunction, out double logNormalizer)
    Parameters
    Type Name Description
    WeightFunctions.MultiRepresentationWeightFunction<TDictionary> normalizedFunction
    Double logNormalizer

    When the function returns, contains the logarithm of the normalizer.

    Returns
    Type Description
    Boolean

    true if the weight function was successfully normalized, false otherwise.

    Zero()

    Creates a weight function which is zero everywhere.

    Declaration
    [Construction(UseWhen = "IsCanonicZero")]
    public static WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.MultiRepresentationWeightFunction<TDictionary> Zero()
    Returns
    Type Description
    WeightFunctions.MultiRepresentationWeightFunction<TDictionary>

    The created weight function

    Implements

    WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.IWeightFunction<TThis>
    WeightFunctions<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>.IWeightFunction
    System.IEquatable<T>
    In This Article
    Back to top Copyright © .NET Foundation. All rights reserved.