File vector_statistic_label_wise_sparse.hpp¶
-
namespace boosting
Functions
-
static inline void addToSparseLabelWiseStatisticVector(View<Triple<float64>>::iterator statistics, SparseSetView<Tuple<float64>>::value_const_iterator begin, SparseSetView<Tuple<float64>>::value_const_iterator end)¶
Adds the statistics that are stored in a single row of a
SparseSetView
to a sparse vector.- Parameters:
statistics – An iterator, the statistics should be added to
begin – An iterator to the beginning of the statistics to be added
end – An iterator to the end of the statistics to be added
-
static inline void addToSparseLabelWiseStatisticVector(View<Triple<float64>>::iterator statistics, SparseSetView<Tuple<float64>>::value_const_iterator begin, SparseSetView<Tuple<float64>>::value_const_iterator end, float64 weight)¶
Adds the statistics that are stored in a single row of a
SparseSetView
to a sparse vector. The statistics are multiplied by a specific weight.- Parameters:
statistics – An iterator, the statistics should be added to
begin – An iterator to the beginning of the statistics to be added
end – An iterator to the end of the statistics to be added
weight – The weight, the statistics should be multiplied by
-
static inline void removeFromSparseLabelWiseStatisticVector(View<Triple<float64>>::iterator statistics, SparseSetView<Tuple<float64>>::value_const_iterator begin, SparseSetView<Tuple<float64>>::value_const_iterator end)¶
Removes the statistics that are stored in a single row of a
SparseSetView
from a sparse vector.- Parameters:
statistics – An iterator, the statistics should be removed from
begin – An iterator to the beginning of the statistics to be removed
end – An iterator to the end of the statistics to be removed
-
static inline void removeFromSparseLabelWiseStatisticVector(View<Triple<float64>>::iterator statistics, SparseSetView<Tuple<float64>>::value_const_iterator begin, SparseSetView<Tuple<float64>>::value_const_iterator end, float64 weight)¶
Removes the statistics that are stored in a single row of a
SparseSetView
from a sparse vector. The statistics are multiplied by a specific weight.- Parameters:
statistics – An iterator, the statistics should be removed from
begin – An iterator to the beginning of the statistics to be removed
end – An iterator to the end of the statistics to be removed
weight – The weight, the statistics should be multiplied by
-
class SparseLabelWiseStatisticVector : public ClearableViewDecorator<VectorDecorator<AllocatedVector<Triple<float64>>>>¶
- #include <vector_statistic_label_wise_sparse.hpp>
An one-dimensional vector that stores aggregated gradients and Hessians that have been calculated using a label-wise decomposable loss function in a C-contiguous array. For each element in the vector a single gradient and Hessian, as well as the sums of the weights of the aggregated gradients and Hessians, is stored.
Public Types
-
typedef ConstIterator const_iterator¶
An iterator that provides read-only access to the elements in the vector.
Public Functions
-
SparseLabelWiseStatisticVector(uint32 numElements, bool init = false)¶
- Parameters:
numElements – The number of gradients and Hessians in the vector
init – True, if all gradients and Hessians in the vector should be initialized with zero, false otherwise
-
SparseLabelWiseStatisticVector(const SparseLabelWiseStatisticVector &other)¶
- Parameters:
other – A reference to an object of type
SparseLabelWiseStatisticVector
to be copied
-
const_iterator cbegin() const¶
Returns a
const_iterator
to the beginning of the vector.- Returns:
A
const_iterator
to the beginning
-
const_iterator cend() const¶
Returns a
const_iterator
to the end of the vector.- Returns:
A
const_iterator
to the end
-
void add(const SparseLabelWiseStatisticVector &vector)¶
Adds all gradients and Hessians in another vector to this vector.
- Parameters:
vector – A reference to an object of type
SparseLabelWiseStatisticVector
that stores the gradients and Hessians to be added to this vector
-
void add(const SparseSetView<Tuple<float64>> &view, uint32 row)¶
Adds all gradients and Hessians in a single row of a
SparseSetView
to this vector.- Parameters:
view – A reference to an object of type
SparseSetView
that stores the gradients and Hessians to be added to this vectorrow – The index of the row to be added to this vector
-
void add(const SparseSetView<Tuple<float64>> &view, uint32 row, float64 weight)¶
Adds all gradients and Hessians in a single row of a
SparseSetView
to this vector. The gradients and Hessians to be added are multiplied by a specific weight.- Parameters:
view – A reference to an object of type
SparseSetView
that stores the gradients and Hessians to be added to this vectorrow – The index of the row to be added to this vector
weight – The weight, the gradients and Hessians should be multiplied by
-
void remove(const SparseSetView<Tuple<float64>> &view, uint32 row)¶
Removes all gradients and Hessians in a single row of a
SparseSetView
from this vector.- Parameters:
view – A reference to an object of type
SparseSetView
that stores the gradients and Hessians to be removed from this vectorrow – The index of the row to be removed from this vector
-
void remove(const SparseSetView<Tuple<float64>> &view, uint32 row, float64 weight)¶
Removes all gradients and Hessians in a single row of a
SparseSetView
from this vector. The gradients and Hessians to be added are multiplied by a specific weight.- Parameters:
view – A reference to an object of type
SparseSetView
that stores the gradients and Hessians to be removed from this vectorrow – The index of the row to be removed from this vector
weight – The weight, the gradients and Hessians should be multiplied by
-
void addToSubset(const SparseSetView<Tuple<float64>> &view, uint32 row, const CompleteIndexVector &indices)¶
Adds certain gradients and Hessians in a single row of a
SparseSetView
, whose positions are given as aCompleteIndexVector
, to this vector.- Parameters:
view – A reference to an object of type
SparseSetView
that stores the gradients and Hessians to be added to this vectorrow – The index of the row to be added to this vector
indices – A reference to a CompleteIndexVector that provides access to the indices
-
void addToSubset(const SparseSetView<Tuple<float64>> &view, uint32 row, const PartialIndexVector &indices)¶
Adds certain gradients and Hessians in a single row of a
SparseSetView
, whose positions are given as aPartialIndexVector
, to this vector.- Parameters:
view – A reference to an object of type
SparseSetView
that stores the gradients and Hessians to be added to this vectorrow – The index of the row to be added to this vector
indices – A reference to a PartialIndexVector that provides access to the indices
-
void addToSubset(const SparseSetView<Tuple<float64>> &view, uint32 row, const CompleteIndexVector &indices, float64 weight)¶
Adds certain gradients and Hessians in a single row of a
SparseSetView
, whose positions are given as aCompleteIndexVector
, to this vector. The gradients and Hessians to be added are multiplied by a specific weight.- Parameters:
view – A reference to an object of type
SparseSetView
that stores the gradients and Hessians to be added to this vectorrow – The index of the row to be added to this vector
indices – A reference to a CompleteIndexVector that provides access to the indices
weight – The weight, the gradients and Hessians should be multiplied by
-
void addToSubset(const SparseSetView<Tuple<float64>> &view, uint32 row, const PartialIndexVector &indices, float64 weight)¶
Adds certain gradients and Hessians in a single row of a
SparsesetView
, whose positions are given as aPartialIndexVector
, to this vector. The gradients and Hessians to be added are multiplied by a specific weight.- Parameters:
view – A reference to an object of type
SparseSetView
that stores the gradients and Hessians to be added to this vectorrow – The index of the row to be added to this vector
indices – A reference to a PartialIndexVector that provides access to the indices
weight – The weight, the gradients and Hessians should be multiplied by
-
void difference(const SparseLabelWiseStatisticVector &first, const CompleteIndexVector &firstIndices, const SparseLabelWiseStatisticVector &second)¶
Sets the gradients and Hessians in this vector to the difference
first - second
between the gradients and Hessians in two other vectors, considering only the gradients and Hessians in the first vector that correspond to the positions provided by aCompleteIndexVector
.- Parameters:
first – A reference to an object of type
SparseLabelWiseStatisticVector
that stores the gradients and Hessians in the first vectorfirstIndices – A reference to an object of type
CompleteIndexVector
that provides access to the indicessecond – A reference to an object of type
SparseLabelWiseStatisticVector
that stores the gradients and Hessians in the second vector
-
void difference(const SparseLabelWiseStatisticVector &first, const PartialIndexVector &firstIndices, const SparseLabelWiseStatisticVector &second)¶
Sets the gradients and Hessians in this vector to the difference
first - second
between the gradients and Hessians in two other vectors, considering only the gradients and Hessians in the first vector that correspond to the positions provided by aPartialIndexVector
.- Parameters:
first – A reference to an object of type
SparseLabelWiseStatisticVector
that stores the gradients and Hessians in the first vectorfirstIndices – A reference to an object of type
PartialIndexVector
that provides access to the indicessecond – A reference to an object of type
SparseLabelWiseStatisticVector
that stores the gradients and Hessians in the second vector
-
void clear() override¶
See also
ClearableViewDecorator::clear
-
class ConstIterator¶
An iterator that provides random read-only access to the statistics in a
SparseLabelWiseStatisticVector
.Public Types
-
typedef int difference_type¶
The type that is used to represent the difference between two iterators.
-
typedef const Tuple<float64> *pointer¶
The type of a pointer to an element, the iterator provides access to.
-
typedef const Tuple<float64> &reference¶
The type of a reference to an element, the iterator provides access to.
-
typedef std::random_access_iterator_tag iterator_category¶
The tag that specifies the capabilities of the iterator.
Public Functions
-
ConstIterator(View<Triple<float64>>::const_iterator iterator, float64 sumOfWeights)¶
- Parameters:
iterator – An iterator that provides access to the elements in a
SparseLabelWiseStatisticVector
sumOfWeights – The sum of the weights of all statistics that have been added to the vector
-
value_type operator[](uint32 index) const¶
Returns the element at a specific index.
- Parameters:
index – The index of the element to be returned
- Returns:
The element at the given index
-
value_type operator*() const¶
Returns the element, the iterator currently refers to.
- Returns:
The element, the iterator currently refers to
-
ConstIterator &operator++()¶
Returns an iterator to the next element.
- Returns:
A reference to an iterator that refers to the next element
-
ConstIterator &operator++(int n)¶
Returns an iterator to the next element.
- Returns:
A reference to an iterator that refers to the next element
-
ConstIterator &operator--()¶
Returns an iterator to the previous element.
- Returns:
A reference to an iterator that refers to the previous element
-
ConstIterator &operator--(int n)¶
Returns an iterator to the previous element.
- Returns:
A reference to an iterator that refers to the previous element
-
bool operator!=(const ConstIterator &rhs) const¶
Returns whether this iterator and another one refer to the same element.
- Parameters:
rhs – A reference to another iterator
- Returns:
True, if the iterators do not refer to the same element, false otherwise
-
bool operator==(const ConstIterator &rhs) const¶
Returns whether this iterator and another one refer to the same element.
- Parameters:
rhs – A reference to another iterator
- Returns:
True, if the iterators refer to the same element, false otherwise
-
difference_type operator-(const ConstIterator &rhs) const¶
Returns the difference between this iterator and another one.
- Parameters:
rhs – A reference to another iterator
- Returns:
The difference between the iterators
-
typedef int difference_type¶
-
typedef ConstIterator const_iterator¶
-
static inline void addToSparseLabelWiseStatisticVector(View<Triple<float64>>::iterator statistics, SparseSetView<Tuple<float64>>::value_const_iterator begin, SparseSetView<Tuple<float64>>::value_const_iterator end)¶