public interface SGDVector extends Tensor, Iterable<VectorTuple>
Tensor
s.
Vectors have immutable sizes and immutable indices (so SparseVector
can't grow).
Modifier and Type | Method and Description |
---|---|
void |
add(int index,
double value)
Adds
value to the element at index . |
SGDVector |
add(SGDVector other)
Adds
other to this vector, producing a new SGDVector . |
SGDVector |
copy()
Returns a deep copy of this vector.
|
default double |
cosineDistance(SGDVector other)
Calculates the cosine distance of two vectors.
|
default double |
cosineSimilarity(SGDVector other)
Calculates the cosine similarity of two vectors.
|
double |
dot(SGDVector other)
Calculates the dot product between this vector and
other . |
double |
euclideanDistance(SGDVector other)
The l2 or euclidean distance between this vector and the other vector.
|
double |
get(int index)
Gets an element from this vector.
|
int |
indexOfMax()
Returns the index of the maximum value.
|
double |
l1Distance(SGDVector other)
The l1 or Manhattan distance between this vector and the other vector.
|
default double |
l2Distance(SGDVector other)
Synonym for euclideanDistance.
|
double |
maxValue()
Returns the maximum value.
|
double |
minValue()
Returns the minimum value.
|
void |
normalize(VectorNormalizer normalizer)
Normalizes the vector using the supplied vector normalizer.
|
int |
numActiveElements()
Returns the number of non-zero elements (on construction, an element
could be set to zero and it would still remain active).
|
double |
oneNorm()
Calculates the Manhattan norm for this vector.
|
Matrix |
outer(SGDVector other)
Generates the matrix representing the outer product between the two vectors.
|
SGDVector |
scale(double coefficient)
Generates a new vector with each element scaled by
coefficient . |
void |
set(int index,
double value)
Sets the
index to the value . |
int |
size()
Returns the dimensionality of this vector.
|
SGDVector |
subtract(SGDVector other)
Subtracts
other from this vector, producing a new SGDVector . |
double |
sum()
Calculates the sum of this vector.
|
double |
twoNorm()
Calculates the euclidean norm for this vector.
|
default double |
variance()
Calculates the variance of this vector.
|
double |
variance(double mean)
Calculates the variance of this vector based on the supplied mean.
|
foreachInPlace, getShape, hadamardProductInPlace, hadamardProductInPlace, intersectAndAddInPlace, intersectAndAddInPlace, reshape, scalarAddInPlace, scaleInPlace, shapeCheck, shapeSum
forEach, iterator, spliterator
SGDVector copy()
int size()
int numActiveElements()
SGDVector scale(double coefficient)
coefficient
.coefficient
- The coefficient to scale the elements by.SGDVector
.void add(int index, double value)
value
to the element at index
.index
- The index to update.value
- The value to add.SGDVector add(SGDVector other)
other
to this vector, producing a new SGDVector
.
Adding Dense to Dense/Sparse produces a DenseVector
, adding Sparse to
Sparse produces a SparseVector
.other
- The vector to add.SGDVector
where each element value = this.get(i) + other.get(i).SGDVector subtract(SGDVector other)
other
from this vector, producing a new SGDVector
.
Subtracting Dense from Dense/Sparse produces a DenseVector
, subtracting Sparse from
Sparse produces a SparseVector
.other
- The vector to subtract.SGDVector
where each element value = this.get(i) - other.get(i).double dot(SGDVector other)
other
.other
- The other vector.Matrix outer(SGDVector other)
double sum()
double twoNorm()
double oneNorm()
double get(int index)
index
- The index of the element.void set(int index, double value)
index
to the value
.index
- The index to set.value
- The value to set it to.int indexOfMax()
double maxValue()
double minValue()
void normalize(VectorNormalizer normalizer)
normalizer
- The kind of normalization to apply.default double l2Distance(SGDVector other)
other
- The other vector.double euclideanDistance(SGDVector other)
other
- The other vector.double l1Distance(SGDVector other)
other
- The other vector.default double cosineDistance(SGDVector other)
other
- The other vector.default double cosineSimilarity(SGDVector other)
other
- The other vector.default double variance()
double variance(double mean)
mean
- The mean of the vector.Copyright © 2015–2021 Oracle and/or its affiliates. All rights reserved.