Function marian::inits::fromSparseVector

Function Documentation

Ptr<NodeInitializer> marian::inits::fromSparseVector(std::pair<std::vector<size_t>, std::vector<float>> &v)

Initialize tensor from a given sparse vector.

Creates a NodeInitializer that will initialize the tensor from a given sparse vector (stored in std::pair). The resulting tensor is first filled with 1e-6 (a placeholder for non-zero element), then set the value to the given sparse vector.


A NodeInitializer

  • v: the sparse vector is stored in std::pair:

    • the first object (v.first) holds the indexes (in a vector)

    • the second object (v.second) holds the corresponding values (in a vector). This means the value of the resulting tensor at index v.first[i] is v.second[i].