NnetDiscriminativeExampleStructureHasher Struct Reference

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

#include <nnet-discriminative-example.h>

Public Member Functions

size_t operator() (const NnetDiscriminativeExample &eg) const noexcept
 
size_t operator() (const NnetDiscriminativeExample *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 136 of file nnet-discriminative-example.h.

Member Function Documentation

◆ operator()() [1/2]

size_t operator() ( const NnetDiscriminativeExample eg) const
noexcept

Definition at line 393 of file nnet-discriminative-example.cc.

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

394  {
395  // these numbers were chosen at random from a list of primes.
396  NnetIoStructureHasher io_hasher;
397  size_t size = eg.inputs.size(), ans = size * 35099;
398  for (size_t i = 0; i < size; i++)
399  ans = ans * 19157 + io_hasher(eg.inputs[i]);
400  for (size_t i = 0; i < eg.outputs.size(); i++) {
401  const NnetDiscriminativeSupervision &sup = eg.outputs[i];
402  StringHasher string_hasher;
403  IndexVectorHasher indexes_hasher;
404  ans = ans * 17957 +
405  string_hasher(sup.name) + indexes_hasher(sup.indexes);
406  }
407  return ans;
408 }

◆ operator()() [2/2]

size_t operator() ( const NnetDiscriminativeExample eg) const
inlinenoexcept

Definition at line 139 of file nnet-discriminative-example.h.

139  {
140  return (*this)(*eg);
141  }

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