Class MaxEntFLGEConstraints
- java.lang.Object
-
- cc.mallet.classify.constraints.ge.MaxEntFLGEConstraints
-
- All Implemented Interfaces:
MaxEntGEConstraint
- Direct Known Subclasses:
MaxEntKLFLGEConstraints,MaxEntL2FLGEConstraints
public abstract class MaxEntFLGEConstraints extends java.lang.Object implements MaxEntGEConstraint
Abstract expectation constraint for use with Generalized Expectation (GE).- Author:
- Gregory Druck
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classMaxEntFLGEConstraints.MaxEntFLGEConstraint
-
Field Summary
Fields Modifier and Type Field Description protected com.carrotsearch.hppc.IntObjectHashMap<MaxEntFLGEConstraints.MaxEntFLGEConstraint>constraintsprotected com.carrotsearch.hppc.IntArrayListindexCacheprotected intnumFeaturesprotected intnumLabelsprotected booleanuseValuesprotected com.carrotsearch.hppc.DoubleArrayListvalueCache
-
Constructor Summary
Constructors Constructor Description MaxEntFLGEConstraints(int numFeatures, int numLabels, boolean useValues)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidaddConstraint(int fi, double[] ex, double weight)voidcomputeExpectations(FeatureVector input, double[] dist, double weight)Compute expectations using provided distribution over labels.doublegetCompositeConstraintFeatureValue(FeatureVector input, int label)Computes the composite constraint feature value (over all constraint features) for FeatureVector fv and label label.voidpreProcess(FeatureVector input)Gives the constraint the option to do some caching using only the FeatureVector.java.util.BitSetpreProcess(InstanceList data)voidzeroExpectations()Zero expectation values.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface cc.mallet.classify.constraints.ge.MaxEntGEConstraint
getValue
-
-
-
-
Field Detail
-
useValues
protected boolean useValues
-
numLabels
protected int numLabels
-
numFeatures
protected int numFeatures
-
constraints
protected com.carrotsearch.hppc.IntObjectHashMap<MaxEntFLGEConstraints.MaxEntFLGEConstraint> constraints
-
indexCache
protected com.carrotsearch.hppc.IntArrayList indexCache
-
valueCache
protected com.carrotsearch.hppc.DoubleArrayList valueCache
-
-
Method Detail
-
addConstraint
public abstract void addConstraint(int fi, double[] ex, double weight)
-
getCompositeConstraintFeatureValue
public double getCompositeConstraintFeatureValue(FeatureVector input, int label)
Description copied from interface:MaxEntGEConstraintComputes the composite constraint feature value (over all constraint features) for FeatureVector fv and label label.- Specified by:
getCompositeConstraintFeatureValuein interfaceMaxEntGEConstraint- Parameters:
input- input FeatureVectorlabel- output label index- Returns:
- Constraint feature value
-
computeExpectations
public void computeExpectations(FeatureVector input, double[] dist, double weight)
Description copied from interface:MaxEntGEConstraintCompute expectations using provided distribution over labels.- Specified by:
computeExpectationsin interfaceMaxEntGEConstraint- Parameters:
input- FeatureVectordist- Distribution over labels
-
zeroExpectations
public void zeroExpectations()
Description copied from interface:MaxEntGEConstraintZero expectation values. Called before re-computing gradient.- Specified by:
zeroExpectationsin interfaceMaxEntGEConstraint
-
preProcess
public java.util.BitSet preProcess(InstanceList data)
- Specified by:
preProcessin interfaceMaxEntGEConstraint- 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.
-
preProcess
public void preProcess(FeatureVector input)
Description copied from interface:MaxEntGEConstraintGives the constraint the option to do some caching using only the FeatureVector. For example, the constrained input features could be cached.- Specified by:
preProcessin interfaceMaxEntGEConstraint- Parameters:
input- FeatureVector input
-
-