NnetChainExampleStructureHasher Struct Reference

This hashing object hashes just the structural aspects of the NnetExample without looking at the value of the features. More...

#include <nnet-chain-example.h>

Public Member Functions

size_t operator() (const NnetChainExample &eg) const noexcept
 
size_t operator() (const NnetChainExample *eg) const noexcept
 

Detailed Description

This hashing object hashes just the structural aspects of the NnetExample without looking at the value of the features.

It will be used in combining egs into batches of all similar structure.

Definition at line 141 of file nnet-chain-example.h.

Member Function Documentation

◆ operator()() [1/2]

size_t operator() ( const NnetChainExample eg) const
noexcept

Definition at line 400 of file nnet-chain-example.cc.

References rnnlm::i, NnetChainSupervision::indexes, and NnetChainSupervision::name.

401  {
402  // these numbers were chosen at random from a list of primes.
403  NnetIoStructureHasher io_hasher;
404  size_t size = eg.inputs.size(), ans = size * 35099;
405  for (size_t i = 0; i < size; i++)
406  ans = ans * 19157 + io_hasher(eg.inputs[i]);
407  for (size_t i = 0; i < eg.outputs.size(); i++) {
408  const NnetChainSupervision &sup = eg.outputs[i];
409  StringHasher string_hasher;
410  IndexVectorHasher indexes_hasher;
411  ans = ans * 17957 +
412  string_hasher(sup.name) + indexes_hasher(sup.indexes);
413  }
414  return ans;
415 }

◆ operator()() [2/2]

size_t operator() ( const NnetChainExample eg) const
inlinenoexcept

Definition at line 144 of file nnet-chain-example.h.

144  {
145  return (*this)(*eg);
146  }

The documentation for this struct was generated from the following files: