NnetExampleStructureHasher Struct Reference

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

#include <nnet-example.h>

Public Member Functions

size_t operator() (const NnetExample &eg) const noexcept
 
size_t operator() (const NnetExample *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. Note: the hash value is sensitive to the order in which the NnetIo elements (input and outputs) appear, even though the merging is capable of dealing with differently-ordered inputs and outputs (e.g. "input" appearing before vs. after "ivector" or "output"). We don't think anyone would ever have to deal with differently-ordered, but otherwise identical, egs in practice so we don't bother making the hashing function independent of this order.

Definition at line 145 of file nnet-example.h.

Member Function Documentation

◆ operator()() [1/2]

size_t operator() ( const NnetExample eg) const
noexcept

Definition at line 162 of file nnet-example.cc.

References rnnlm::i.

163  {
164  // these numbers were chosen at random from a list of primes.
165  NnetIoStructureHasher io_hasher;
166  size_t size = eg.io.size(), ans = size * 35099;
167  for (size_t i = 0; i < size; i++)
168  ans = ans * 19157 + io_hasher(eg.io[i]);
169  return ans;
170 }

◆ operator()() [2/2]

size_t operator() ( const NnetExample eg) const
inlinenoexcept

Definition at line 148 of file nnet-example.h.

148  {
149  return (*this)(*eg);
150  }

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