Class OneLabelGEConstraints

  • All Implemented Interfaces:
    GEConstraint
    Direct Known Subclasses:
    OneLabelKLGEConstraints, OneLabelL2GEConstraints

    public abstract class OneLabelGEConstraints
    extends java.lang.Object
    implements GEConstraint
    A set of constraints on distributions over single labels conditioned on the presence of input features. Subclasses are to be used with GE. Multiple constraints are grouped together here to make things more efficient.
    Author:
    Gregory Druck
    • Method Detail

      • addConstraint

        public abstract void addConstraint​(int fi,
                                           double[] target,
                                           double weight)
      • isOneStateConstraint

        public boolean isOneStateConstraint()
        Specified by:
        isOneStateConstraint in interface GEConstraint
        Returns:
        true if constraint feature only considers one state
      • setStateLabelMap

        public void setStateLabelMap​(StateLabelMap map)
        Description copied from interface: GEConstraint
        Sets that map between the state indices and label indices.
        Specified by:
        setStateLabelMap in interface GEConstraint
        Parameters:
        map - StateLabelMap
      • preProcess

        public void preProcess​(FeatureVector fv)
        Description copied from interface: GEConstraint
        Gives the constraint the option to do some caching using only the FeatureVector. For example, the constrained input features could be cached.
        Specified by:
        preProcess in interface GEConstraint
        Parameters:
        fv - FeatureVector input
      • preProcess

        public java.util.BitSet preProcess​(InstanceList data)
        Specified by:
        preProcess in interface GEConstraint
        Parameters:
        data - Unlabeled data
        Returns:
        Returns a bitset of the size of the data, with the bit set if a constraint feature fires in that instance.
      • getCompositeConstraintFeatureValue

        public double getCompositeConstraintFeatureValue​(FeatureVector fv,
                                                         int ip,
                                                         int si1,
                                                         int si2)
        Description copied from interface: GEConstraint
        Computes the composite constraint feature value (over all constraint features) for FeatureVector fv and a transition from state li1 to li2.
        Specified by:
        getCompositeConstraintFeatureValue in interface GEConstraint
        Parameters:
        fv - FeatureVector on transition
        ip - Position of input in sequence
        si1 - Source state index for transition
        si2 - Destination state index for transition
        Returns:
        Constraint feature value
      • getValue

        public abstract double getValue()
        Description copied from interface: GEConstraint
        Returns the total constraint value.
        Specified by:
        getValue in interface GEConstraint
        Returns:
        Constraint value
      • zeroExpectations

        public void zeroExpectations()
        Description copied from interface: GEConstraint
        Zero expectation values. Called before re-computing gradient.
        Specified by:
        zeroExpectations in interface GEConstraint
      • computeExpectations

        public void computeExpectations​(java.util.ArrayList<SumLattice> lattices)
        Description copied from interface: GEConstraint
        Compute expectations using cached lattices.
        Specified by:
        computeExpectations in interface GEConstraint
        Parameters:
        lattices - Cached SumLattices