cc.mallet.fst.semi_supervised.constraints
Class OneLabelL2RangeGEConstraints
- java.lang.Object
-
- cc.mallet.fst.semi_supervised.constraints.OneLabelL2RangeGEConstraints
-
- All Implemented Interfaces:
- GEConstraint
public class OneLabelL2RangeGEConstraints extends java.lang.Object implements GEConstraint
A set of constraints on individual input feature label pairs. This is to be used with GE, and penalizes the L_2^2 difference between model and target distributions. Multiple constraints are grouped together here to make things more efficient.
-
-
Constructor Summary
Constructors Constructor and Description OneLabelL2RangeGEConstraints()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddConstraint(int fi, int li, double lower, double upper, double weight)voidcomputeExpectations(java.util.ArrayList<SumLattice> lattices)Compute expectations using cached lattices.GEConstraintcopy()This is used in multi-threading.doublegetCompositeConstraintFeatureValue(FeatureVector fv, int ip, int si1, int si2)Computes the composite constraint feature value (over all constraint features) for FeatureVector fv and a transition from state li1 to li2.doublegetValue()Returns the total constraint value.booleanisOneStateConstraint()voidpreProcess(FeatureVector fv)Gives the constraint the option to do some caching using only the FeatureVector.java.util.BitSetpreProcess(InstanceList data)voidsetStateLabelMap(StateLabelMap map)Sets that map between the state indices and label indices.voidzeroExpectations()Zero expectation values.
-
-
-
Method Detail
-
addConstraint
public void addConstraint(int fi, int li, double lower, double upper, double weight)
-
isOneStateConstraint
public boolean isOneStateConstraint()
- Specified by:
isOneStateConstraintin interfaceGEConstraint- Returns:
- true if constraint feature only considers one state
-
setStateLabelMap
public void setStateLabelMap(StateLabelMap map)
Description copied from interface:GEConstraintSets that map between the state indices and label indices.- Specified by:
setStateLabelMapin interfaceGEConstraint- Parameters:
map- StateLabelMap
-
preProcess
public void preProcess(FeatureVector fv)
Description copied from interface:GEConstraintGives the constraint the option to do some caching using only the FeatureVector. For example, the constrained input features could be cached.- Specified by:
preProcessin interfaceGEConstraint- Parameters:
fv- FeatureVector input
-
preProcess
public java.util.BitSet preProcess(InstanceList data)
- Specified by:
preProcessin interfaceGEConstraint- 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:GEConstraintComputes the composite constraint feature value (over all constraint features) for FeatureVector fv and a transition from state li1 to li2.- Specified by:
getCompositeConstraintFeatureValuein interfaceGEConstraint- Parameters:
fv- FeatureVector on transitionip- Position of input in sequencesi1- Source state index for transitionsi2- Destination state index for transition- Returns:
- Constraint feature value
-
getValue
public double getValue()
Description copied from interface:GEConstraintReturns the total constraint value.- Specified by:
getValuein interfaceGEConstraint- Returns:
- Constraint value
-
zeroExpectations
public void zeroExpectations()
Description copied from interface:GEConstraintZero expectation values. Called before re-computing gradient.- Specified by:
zeroExpectationsin interfaceGEConstraint
-
computeExpectations
public void computeExpectations(java.util.ArrayList<SumLattice> lattices)
Description copied from interface:GEConstraintCompute expectations using cached lattices.- Specified by:
computeExpectationsin interfaceGEConstraint- Parameters:
lattices- Cached SumLattices
-
copy
public GEConstraint copy()
Description copied from interface:GEConstraintThis is used in multi-threading.- Specified by:
copyin interfaceGEConstraint- Returns:
- A copy of the GEConstraint.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG