|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectcontextFold.features.AbstractFeatureVector
contextFold.features.DenseFeatureVector
public class DenseFeatureVector
A dense implementation of a feature vector
Field Summary | |
---|---|
protected float[] |
acc
|
protected int |
dimension
|
protected int[] |
intWeights
|
protected boolean |
isCompressed
|
protected int[] |
upd
|
protected int |
updateTime
|
protected float[] |
weights
|
Fields inherited from class contextFold.features.AbstractFeatureVector |
---|
featureNames |
Constructor Summary | |
---|---|
DenseFeatureVector(DenseFeatureVector toCopy)
A copy constructor. |
|
DenseFeatureVector(int dimension)
A constructor. |
|
DenseFeatureVector(int length,
float epsilon)
A constructor. |
Method Summary | |
---|---|
void |
add(AbstractFeatureVector other)
The same as AbstractFeatureVector.add(AbstractFeatureVector, float) , where
amount = 1. |
void |
average()
Setting weights to the average values over all updates. |
void |
clear()
Sets all weights to 0. |
void |
compress()
|
void |
compress(int intRange)
Maps all float weights to the given range of integers. |
int |
countNonZeroEntries()
|
int |
dim()
|
float |
dot(AbstractFeatureVector other)
Computes the dot-product of two vectors. |
float |
getFeatureWeight(int featureIx)
|
java.util.Iterator<java.lang.Integer> |
getNonZeroFeatures()
|
int |
getUpdateTime()
|
float |
max()
|
float |
min()
|
DenseFeatureVector |
newEmpty()
|
float |
norm()
|
void |
setFeatureWeight(int featureIx,
float newFeatureWeight)
Sets the weight of a given feature. |
void |
sub(AbstractFeatureVector other)
The same as AbstractFeatureVector.sub(AbstractFeatureVector, float) , where
amount = 1. |
void |
sub(AbstractFeatureVector other,
float amount)
The same as AbstractFeatureVector.add(AbstractFeatureVector, float) , where
other is being subtracted rather than added. |
void |
tick()
Increases time stamp by one. |
void |
uncompress()
|
void |
update(AbstractFeatureVector other,
float s)
Executes add(other, s), while maintaining an inner state that allows averaging over all updates. |
Methods inherited from class contextFold.features.AbstractFeatureVector |
---|
add, filter, setFeatureNames, sum |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected float[] weights
protected float[] acc
protected int[] upd
protected int[] intWeights
protected int dimension
protected int updateTime
protected boolean isCompressed
Constructor Detail |
---|
public DenseFeatureVector(int dimension)
dimension
- the length of the constructed vector.public DenseFeatureVector(int length, float epsilon)
length
- the length of the constructed vector.epsilon
- an initial value to set in all the entries.public DenseFeatureVector(DenseFeatureVector toCopy)
toCopy
- the vector to be copied.Method Detail |
---|
public int getUpdateTime()
public float dot(AbstractFeatureVector other)
Dotable
dot
in interface Dotable<AbstractFeatureVector>
dot
in class AbstractFeatureVector
other
- another vector.
this
and other
.public void add(AbstractFeatureVector other)
AbstractFeatureVector
AbstractFeatureVector.add(AbstractFeatureVector, float)
, where
amount
= 1.
add
in class AbstractFeatureVector
other
- a weight vector to be added.public void sub(AbstractFeatureVector other, float amount)
AbstractFeatureVector
AbstractFeatureVector.add(AbstractFeatureVector, float)
, where
other
is being subtracted rather than added.
sub
in class AbstractFeatureVector
other
- a weight vector to be subtracted.amount
- a scaling parameter.public void sub(AbstractFeatureVector other)
AbstractFeatureVector
AbstractFeatureVector.sub(AbstractFeatureVector, float)
, where
amount
= 1.
sub
in class AbstractFeatureVector
other
- a weight vector to be subtracted.public void tick()
public void update(AbstractFeatureVector other, float s)
other
- s
- public void average()
public DenseFeatureVector newEmpty()
public int dim()
public float getFeatureWeight(int featureIx)
getFeatureWeight
in class AbstractFeatureVector
featureIx
- an index of a feature.
featureIx
.public java.util.Iterator<java.lang.Integer> getNonZeroFeatures()
getNonZeroFeatures
in class AbstractFeatureVector
public void setFeatureWeight(int featureIx, float newFeatureWeight)
AbstractFeatureVector
setFeatureWeight
in class AbstractFeatureVector
featureIx
- an index of a feature.newFeatureWeight
- a value to be set as the weight of
the feature which index is featureIx
.public void clear()
AbstractFeatureVector
clear
in class AbstractFeatureVector
public float norm()
norm
in class AbstractFeatureVector
public int countNonZeroEntries()
countNonZeroEntries
in class AbstractFeatureVector
public float max()
public float min()
public void compress()
public void compress(int intRange)
uncompress()
method (otherwise, exceptions will be
thrown). In addition, compression deletes information which is
required for averaging the vector.
intRange
- the range of integers to which the weights are mapped.public void uncompress()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |