matchzoo.dataloader.callbacks.histogram

Module Contents

class matchzoo.dataloader.callbacks.histogram.Histogram(embedding_matrix:np.ndarray, bin_size:int=30, hist_mode:str='CH')

Bases: matchzoo.engine.base_callback.BaseCallback

Generate data with matching histogram.

Parameters:
  • embedding_matrix – The embedding matrix used to generator match histogram.
  • bin_size – The number of bin size of the histogram.
  • hist_mode – The mode of the MatchingHistogramUnit, one of CH, NH, and LCH.
on_batch_unpacked(self, x, y)

Insert match_histogram to x.

matchzoo.dataloader.callbacks.histogram._trunc_text(input_text:list, length:list) → list

Truncating the input text according to the input length.

Parameters:
  • input_text – The input text need to be truncated.
  • length – The length used to truncated the text.
Returns:

The truncated text.

matchzoo.dataloader.callbacks.histogram._build_match_histogram(x:dict, match_hist_unit:mz.preprocessors.units.MatchingHistogram) → np.ndarray

Generate the matching hisogram for input.

Parameters:
  • x – The input dict.
  • match_hist_unit – The histogram unit MatchingHistogramUnit.
Returns:

The matching histogram.