public class ShrinkingVector extends DenseVector implements ShrinkingTensor
DenseVector
which shrinks the value every time a new value is added.
Be careful when modifying this or DenseVector
.
elements
tolerance
Constructor and Description |
---|
ShrinkingVector(DenseVector v,
double baseRate,
boolean scaleShrinking) |
ShrinkingVector(DenseVector v,
double baseRate,
double lambda) |
Modifier and Type | Method and Description |
---|---|
DenseVector |
convertToDense() |
ShrinkingVector |
copy()
Returns a deep copy of this vector.
|
double |
dot(SGDVector other)
Calculates the dot product between this vector and
other . |
double |
get(int index)
Gets an element from this vector.
|
int |
indexOfMax()
Returns the index of the maximum value.
|
void |
intersectAndAddInPlace(Tensor other,
DoubleUnaryOperator f)
Updates this
Tensor by adding all the values from the intersection with other . |
VectorIterator |
iterator() |
double |
maxValue()
Returns the maximum value.
|
double |
minValue()
Returns the minimum value.
|
void |
scaleInPlace(double value)
Scales each element of this
Tensor by coefficient . |
double |
sum()
Calculates the sum of this vector.
|
double[] |
toArray()
Generates a copy of the values in this DenseVector.
|
double |
twoNorm()
Calculates the euclidean norm for this vector.
|
add, add, createDenseVector, createDenseVector, equals, euclideanDistance, expNormalize, fill, foreachInPlace, getShape, hadamardProductInPlace, hashCode, l1Distance, normalize, numActiveElements, oneNorm, outer, reduce, reshape, scale, set, setElements, size, sparsify, sparsify, subtract, sum, toString, variance
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
cosineDistance, cosineSimilarity, l2Distance, variance
hadamardProductInPlace, intersectAndAddInPlace, scalarAddInPlace, shapeCheck, shapeSum
forEach, spliterator
public ShrinkingVector(DenseVector v, double baseRate, boolean scaleShrinking)
public ShrinkingVector(DenseVector v, double baseRate, double lambda)
public DenseVector convertToDense()
convertToDense
in interface ShrinkingTensor
public ShrinkingVector copy()
SGDVector
copy
in interface SGDVector
copy
in class DenseVector
public double[] toArray()
DenseVector
This implementation uses Arrays.copyOf, and should be overridden if the get function has been modified.
toArray
in interface SGDVector
toArray
in class DenseVector
public double get(int index)
SGDVector
get
in interface SGDVector
get
in class DenseVector
index
- The index of the element.public double sum()
SGDVector
sum
in interface SGDVector
sum
in class DenseVector
public void intersectAndAddInPlace(Tensor other, DoubleUnaryOperator f)
Tensor
Tensor
by adding all the values from the intersection with other
.
The function f
is applied to all values from other
before the
addition.
Each value is updated as value += f(otherValue).
intersectAndAddInPlace
in interface Tensor
intersectAndAddInPlace
in class DenseVector
other
- The other Tensor
.f
- A function to apply.public int indexOfMax()
SGDVector
indexOfMax
in interface SGDVector
indexOfMax
in class DenseVector
public double dot(SGDVector other)
SGDVector
other
.dot
in interface SGDVector
dot
in class DenseVector
other
- The other vector.public void scaleInPlace(double value)
Tensor
Tensor
by coefficient
.scaleInPlace
in interface Tensor
value
- The coefficient of scaling.public double twoNorm()
SGDVector
public double maxValue()
SGDVector
maxValue
in interface SGDVector
maxValue
in class DenseVector
public double minValue()
SGDVector
minValue
in interface SGDVector
minValue
in class DenseVector
public VectorIterator iterator()
iterator
in interface Iterable<VectorTuple>
iterator
in class DenseVector
Copyright © 2015–2021 Oracle and/or its affiliates. All rights reserved.