public class BiasedRandomWeightVector extends RandomWeightVector
RandomWeightVector
class that it extends, except that this vector also
contains a bias term (also initialized randomly) which is added to every dot product and affected
by every vector addition operation.Modifier and Type | Field and Description |
---|---|
protected double |
bias
The current bias weight.
|
defaultStddev, instanceNumber, random, stddev
defaultCapacity, defaultWeight, weights
Constructor and Description |
---|
BiasedRandomWeightVector()
Instantiates this biased vector with a random bias.
|
BiasedRandomWeightVector(double s)
Sets the specified standard deviation and a random bias.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Empties the weight map and resets the random number generator.
|
double |
dot(int[] exampleFeatures,
double[] exampleValues,
double defaultW)
Takes the dot product of this
BiasedRandomWeightVector with the argument vector,
using the specified default weight when one is not yet present in this vector. |
SparseWeightVector |
emptyClone()
Returns a new, empty weight vector with the same parameter settings as this one.
|
void |
scaledAdd(int[] exampleFeatures,
double[] exampleValues,
double factor,
double defaultW)
Self-modifying vector addition where the argument vector is first scaled by the given factor.
|
void |
write(edu.illinois.cs.cogcomp.core.datastructures.vectors.ExceptionlessOutputStream out)
Writes the weight vector's internal representation in binary form.
|
void |
write(PrintStream out)
Outputs a textual representation of this vector to the specified stream.
|
void |
write(PrintStream out,
Lexicon lex)
Outputs a textual representation of this vector to the specified stream.
|
getWeight, read
clone, dot, getWeight, pairwiseMultiply, readWeightVector, scaledAdd, scaledAdd, scaledMultiply, scaledMultiply, setWeight, setWeight, size, toString, toString, toStringJustWeights, toStringJustWeights
public BiasedRandomWeightVector()
public BiasedRandomWeightVector(double s)
s
- The standard deviation.public double dot(int[] exampleFeatures, double[] exampleValues, double defaultW)
BiasedRandomWeightVector
with the argument vector,
using the specified default weight when one is not yet present in this vector.dot
in class SparseWeightVector
exampleFeatures
- The example's array of feature indicesexampleValues
- The example's array of feature valuesdefaultW
- The default weight.public void scaledAdd(int[] exampleFeatures, double[] exampleValues, double factor, double defaultW)
scaledAdd
in class SparseWeightVector
exampleFeatures
- The example's array of feature indicesexampleValues
- The example's array of feature valuesfactor
- The scaling factor.defaultW
- An initial weight for previously unseen features.public void clear()
dot(int[],double[],double)
and scaledAdd(int[],double[],double,double)
are
made in the same order.clear
in class RandomWeightVector
public void write(PrintStream out)
SparseWeightVector.write(PrintStream)
, with two
added lines just after the "Begin"
annotation that give the values of
RandomWeightVector.stddev
and bias
.write
in class RandomWeightVector
out
- The stream to write to.public void write(PrintStream out, Lexicon lex)
SparseWeightVector.write(PrintStream)
, with two
added lines just after the "Begin"
annotation that give the values of
RandomWeightVector.stddev
and bias
.write
in class RandomWeightVector
out
- The stream to write to.lex
- The feature lexicon.public void write(edu.illinois.cs.cogcomp.core.datastructures.vectors.ExceptionlessOutputStream out)
write
in class RandomWeightVector
out
- The output stream.public SparseWeightVector emptyClone()
emptyClone
in class RandomWeightVector
Copyright © 2016. All rights reserved.