Class ShrinkingVector
java.lang.Object
org.tribuo.math.la.DenseVector
org.tribuo.math.optimisers.util.ShrinkingVector
- All Implemented Interfaces:
Serializable
,Iterable<VectorTuple>
,SGDVector
,Tensor
,ShrinkingTensor
A subclass of
DenseVector
which shrinks the value every time a new value is added.
Be careful when modifying this or DenseVector
.
- See Also:
-
Field Summary
Fields inherited from class org.tribuo.math.la.DenseVector
elements
Fields inherited from interface org.tribuo.math.optimisers.util.ShrinkingTensor
tolerance
-
Constructor Summary
ConstructorsConstructorDescriptionShrinkingVector
(DenseVector v, double baseRate, boolean scaleShrinking) ShrinkingVector
(DenseVector v, double baseRate, double lambda) -
Method Summary
Modifier and TypeMethodDescriptioncopy()
Returns a deep copy of this vector.double
Calculates the dot product between this vector andother
.double
get
(int index) Gets an element from this vector.int
Returns the index of the maximum value.void
intersectAndAddInPlace
(Tensor other, DoubleUnaryOperator f) Updates thisTensor
by adding all the values from the intersection withother
.iterator()
double
maxValue()
Returns the maximum value.double
minValue()
Returns the minimum value.void
scaleInPlace
(double value) Scales each element of thisTensor
bycoefficient
.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.Methods inherited from class org.tribuo.math.la.DenseVector
add, add, 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
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface org.tribuo.math.la.SGDVector
cosineDistance, cosineSimilarity, l2Distance, variance
Methods inherited from interface org.tribuo.math.la.Tensor
hadamardProductInPlace, intersectAndAddInPlace, scalarAddInPlace
-
Constructor Details
-
ShrinkingVector
-
ShrinkingVector
-
-
Method Details
-
convertToDense
- Specified by:
convertToDense
in interfaceShrinkingTensor
-
copy
Description copied from interface:SGDVector
Returns a deep copy of this vector.- Specified by:
copy
in interfaceSGDVector
- Overrides:
copy
in classDenseVector
- Returns:
- A copy of this vector.
-
toArray
Description copied from class:DenseVector
Generates a copy of the values in this DenseVector.This implementation uses Arrays.copyOf, and should be overridden if the get function has been modified.
- Overrides:
toArray
in classDenseVector
- Returns:
- A copy of the values in this DenseVector.
-
get
-
sum
-
intersectAndAddInPlace
Description copied from interface:Tensor
Updates thisTensor
by adding all the values from the intersection withother
.The function
f
is applied to all values fromother
before the addition.Each value is updated as value += f(otherValue).
- Specified by:
intersectAndAddInPlace
in interfaceTensor
- Overrides:
intersectAndAddInPlace
in classDenseVector
- Parameters:
other
- The otherTensor
.f
- A function to apply.
-
indexOfMax
Description copied from interface:SGDVector
Returns the index of the maximum value. Requires probing the array.- Specified by:
indexOfMax
in interfaceSGDVector
- Overrides:
indexOfMax
in classDenseVector
- Returns:
- The index of the maximum value.
-
dot
-
scaleInPlace
Description copied from interface:Tensor
Scales each element of thisTensor
bycoefficient
.- Specified by:
scaleInPlace
in interfaceTensor
- Parameters:
value
- The coefficient of scaling.
-
twoNorm
-
maxValue
-
minValue
-
iterator
- Specified by:
iterator
in interfaceIterable<VectorTuple>
- Overrides:
iterator
in classDenseVector
-