kaldi.tree

Functions

add_to_clusters Calls C++ function
add_to_clusters_optimized Calls C++ function
build_tree Builds a set of decision trees.
build_tree_two_level Builds a two-level decision tree.
cluster_bottom_up Calls C++ function
cluster_bottom_up_compartmentalized Calls C++ function
cluster_event_map_get_mapping Clusters the leaves of the EventMap, with ‘thresh’ a delta-likelihood threshold to control how many leaves we combine.
convert_stats Converts stats from a given context-window (N) and central position (P) to a different N and P
find_all_keys Returns the sorted and unique list of all key identities in the stats.
gen_rand_stats Generates random statistics of the form used by build_tree.
get_tree_structure Calls C++ function
make_event_pair Calls C++ function
map_event_map_leaves Remaps the event-map leaves using this mapping indexed by number of leaf
monophone_context_dependency Returns a new ContextDependency object for a monophone system.
monophone_context_dependency_shared Returns a new ContextDependency object for a monophone system with shared PDFs.
objf_given_map Cluster the stats given the event map return the total objf given those clusters
possible_values Convenienve function to work out possible values of the phones from just the stats.
read_build_tree_stats Reads BuildTreeStatsType object.
read_event_type Calls C++ function
read_roots_file Reads roots from file.
read_symbol_table_as_integers Reads a symbol table, discards the symbols and returns the indexes.
split_decision_tree Calls C++ function
split_stats_by_key Splits stats up according to the value of a particular key, which must be always defined and nonnegative.
split_stats_by_map Splits stats according to the EventMap, indexing them at output by the leaf type.
sum_clusterable Calls C++ function
sum_clusterable_normalizer Calls C++ function
sum_clusterable_objf Calls C++ function
sum_normalizer Sums the normalizer over the stats
sum_objf Sums the objective function over the stats
sum_stats Sums stats
sum_stats_vec Sum a vector of stats
write_build_tree_stats Writes BuildTreeStatsType.
write_event_type Calls C++ function

Classes

AllKeysType An enumeration.
ClusterKMeansOptions CLIF wrapper for ::kaldi::ClusterKMeansOptions
ConstantEventMap CLIF wrapper for ::kaldi::ConstantEventMap
ContextDependency Phonetic decision tree.
EventMap CLIF wrapper for ::kaldi::EventMap
GaussClusterable CLIF wrapper for ::kaldi::GaussClusterable
Questions CLIF wrapper for ::kaldi::Questions
QuestionsForKey CLIF wrapper for ::kaldi::QuestionsForKey
RefineClustersOptions CLIF wrapper for ::kaldi::RefineClustersOptions
ScalarClusterable CLIF wrapper for ::kaldi::ScalarClusterable
SplitEventMap CLIF wrapper for ::kaldi::SplitEventMap
TableEventMap CLIF wrapper for ::kaldi::TableEventMap
TreeClusterOptions CLIF wrapper for ::kaldi::TreeClusterOptions
TreeRenderer CLIF wrapper for ::kaldi::TreeRenderer
VectorClusterable CLIF wrapper for ::kaldi::VectorClusterable
class kaldi.tree.AllKeysType

An enumeration.

ALL_KEYS_INSIST_IDENTICAL = 0
ALL_KEYS_INTERSECTION = 1
ALL_KEYS_UNION = 2
class kaldi.tree.ClusterKMeansOptions

CLIF wrapper for ::kaldi::ClusterKMeansOptions

num_iters

C++ ::int32 ClusterKMeansOptions.num_iters

num_tries

C++ ::int32 ClusterKMeansOptions.num_tries

refine_cfg

C++ ::kaldi::RefineClustersOptions ClusterKMeansOptions.refine_cfg

verbose

C++ bool ClusterKMeansOptions.verbose

class kaldi.tree.ConstantEventMap

CLIF wrapper for ::kaldi::ConstantEventMap

check(event:list<tuple<int, int>>)

Calls C++ function void ::kaldi::EventMap::Check(::kaldi::EventType)

copy() → EventMap

Calls C++ function ::kaldi::EventMap * ::kaldi::EventMap::Copy()

copy_with_new_leaves(new_leaves:list<EventMap>) → EventMap

Calls C++ function ::kaldi::EventMap * ::kaldi::ConstantEventMap::Copy(::std::vector< ::kaldi::EventMap *>)

get_children() → list<EventMap>

Calls C++ function void ::kaldi::ConstantEventMap::GetChildren(::std::vector< ::kaldi::EventMap >)

lookup(event:list<tuple<int, int>>, key:int) -> (success:bool, ans:int)

Calls C++ function bool ::kaldi::EventMap::Lookup(::kaldi::EventType, int, int*)

map(event:list<tuple<int, int>>) -> (success:bool, ans:int)

Calls C++ function bool ::kaldi::ConstantEventMap::Map(::kaldi::EventType, int*)

map_values(keys_to_map:set<int>, value_map:dict<int, int>) → EventMap

Calls C++ function ::kaldi::EventMap * ::kaldi::ConstantEventMap::MapValues(::std::unordered_set< ::kaldi::EventKeyType>, ::std::unordered_map< ::kaldi::EventValueType, ::kaldi::EventValueType>)

max_result() → int

Calls C++ function int ::kaldi::EventMap::MaxResult()

multi_map(event:list<tuple<int, int>>) → list<int>

Calls C++ function void ::kaldi::ConstantEventMap::MultiMap(::kaldi::EventType, ::std::vector< ::kaldi::EventAnswerType>*)

prune() → EventMap

Calls C++ function ::kaldi::EventMap * ::kaldi::ConstantEventMap::Prune()

read(is:istream, binary:bool) → ConstantEventMap

Calls C++ function ::kaldi::ConstantEventMap * ::kaldi::ConstantEventMap::Read(::std::basic_istream<char, ::std::char_traits<char> >, bool)

read_event_map(is:istream, binary:bool) → EventMap

Calls C++ function ::kaldi::EventMap * ::kaldi::EventMap::Read(::std::basic_istream<char, ::std::char_traits<char> >, bool)

write(os:ostream, binary:bool)

Calls C++ function void ::kaldi::ConstantEventMap::Write(::std::basic_ostream<char, ::std::char_traits<char> >, bool)

write_event_map(os:ostream, binary:bool, emap:EventMap)

Calls C++ function void ::kaldi::EventMap::Write(::std::basic_ostream<char, ::std::char_traits<char> >, bool, ::kaldi::EventMap *)

write_to_stream(os:ostream, binary:bool)

Calls C++ function void ::kaldi::EventMap::Write(::std::basic_ostream<char, ::std::char_traits<char> >, bool)

class kaldi.tree.ContextDependency

Phonetic decision tree.

central_position() → int

Returns central position of the context.

compute(phoneseq:list<int>, pdf_class:int) -> (success:bool, pdf_id:int)

Returns the pdf-id for given phone seq and pdf class.

context_width() → int

Returns context width.

copy() → ContextDependencyInterface

Returns a copy of this object.

from_event_map(N:int, P:int, to_pdf:EventMap) → ContextDependency

Constructs a new ContextDependency object from an event map.

get_pdf_info(phones:list<int>, num_pdf_classes:list<int>) → list<list<tuple<int, int>>>

Returns the list of (phone, pdf-id) pairs each pdf-id can correspond to.

get_pdf_pair_info(phones:list<int>, pdf_class_pairs:list<list<tuple<int, int>>>) → list<list<list<tuple<int, int>>>>

Returns indo about what possible pdf-ids can be generated for HMM-states.

num_pdfs() → int

Returns the number of PDFs.

read(is:istream, binary:bool)

Reads the object from an input stream.

to_pdf_map() → EventMap

Returns the event map.

write(os:ostream, binary:bool)

Writes the object to an output stream.

class kaldi.tree.EventMap

CLIF wrapper for ::kaldi::EventMap

check(event:list<tuple<int, int>>)

Calls C++ function void ::kaldi::EventMap::Check(::kaldi::EventType)

copy() → EventMap

Calls C++ function ::kaldi::EventMap * ::kaldi::EventMap::Copy()

copy_with_new_leaves(new_leaves:list<EventMap>) → EventMap

Calls C++ function ::kaldi::EventMap * ::kaldi::EventMap::Copy(::std::vector< ::kaldi::EventMap *>)

get_children() → list<EventMap>

Calls C++ function void ::kaldi::EventMap::GetChildren(::std::vector< ::kaldi::EventMap >)

lookup(event:list<tuple<int, int>>, key:int) -> (success:bool, ans:int)

Calls C++ function bool ::kaldi::EventMap::Lookup(::kaldi::EventType, int, int*)

map(event:list<tuple<int, int>>) -> (success:bool, ans:int)

Calls C++ function bool ::kaldi::EventMap::Map(::kaldi::EventType, int*)

map_values(keys_to_map:set<int>, value_map:dict<int, int>) → EventMap

Calls C++ function ::kaldi::EventMap * ::kaldi::EventMap::MapValues(::std::unordered_set< ::kaldi::EventKeyType>, ::std::unordered_map< ::kaldi::EventValueType, ::kaldi::EventValueType>)

max_result() → int

Calls C++ function int ::kaldi::EventMap::MaxResult()

multi_map(event:list<tuple<int, int>>) → list<int>

Calls C++ function void ::kaldi::EventMap::MultiMap(::kaldi::EventType, ::std::vector< ::kaldi::EventAnswerType>*)

prune() → EventMap

Calls C++ function ::kaldi::EventMap * ::kaldi::EventMap::Prune()

read_event_map(is:istream, binary:bool) → EventMap

Calls C++ function ::kaldi::EventMap * ::kaldi::EventMap::Read(::std::basic_istream<char, ::std::char_traits<char> >, bool)

write_event_map(os:ostream, binary:bool, emap:EventMap)

Calls C++ function void ::kaldi::EventMap::Write(::std::basic_ostream<char, ::std::char_traits<char> >, bool, ::kaldi::EventMap *)

write_to_stream(os:ostream, binary:bool)

Calls C++ function void ::kaldi::EventMap::Write(::std::basic_ostream<char, ::std::char_traits<char> >, bool)

class kaldi.tree.GaussClusterable

CLIF wrapper for ::kaldi::GaussClusterable

add(other:Clusterable)

Calls C++ function void ::kaldi::GaussClusterable::Add(::kaldi::Clusterable)

add_stats(vec:VectorBase, weight:float=default)

Calls C++ function void ::kaldi::GaussClusterable::AddStats(::kaldi::VectorBase<float>, float)

copy() → Clusterable

Calls C++ function ::kaldi::Clusterable * ::kaldi::GaussClusterable::Copy()

count() → float

Calls C++ function float ::kaldi::GaussClusterable::count()

distance(other:Clusterable) → float

Calls C++ function float ::kaldi::Clusterable::Distance(::kaldi::Clusterable)

new_with_dim(dim:int, var_floor:float) → GaussClusterable

Calls C++ function std::unique_ptr<::kaldi::GaussClusterable> ::kaldi::GaussClusterable::GaussClusterable(int, float)

new_with_stats(x_stats:Vector, x2_stats:Vector, var_floor:float, count:float) → GaussClusterable

Calls C++ function std::unique_ptr<::kaldi::GaussClusterable> ::kaldi::GaussClusterable::GaussClusterable(::kaldi::Vector<float>, ::kaldi::Vector<float>, float, float)

normalizer() → float

Calls C++ function float ::kaldi::GaussClusterable::Normalizer()

objf() → float

Calls C++ function float ::kaldi::GaussClusterable::Objf()

objf_minus(other:Clusterable) → float

Calls C++ function float ::kaldi::Clusterable::ObjfMinus(::kaldi::Clusterable)

objf_plus(other:Clusterable) → float

Calls C++ function float ::kaldi::Clusterable::ObjfPlus(::kaldi::Clusterable)

read_new(is:istream, binary:bool) → Clusterable

Calls C++ function ::kaldi::Clusterable * ::kaldi::GaussClusterable::ReadNew(::std::basic_istream<char, ::std::char_traits<char> >, bool)

scale(f:float)

Calls C++ function void ::kaldi::GaussClusterable::Scale(float)

set_zero()

Calls C++ function void ::kaldi::GaussClusterable::SetZero()

sub(other:Clusterable)

Calls C++ function void ::kaldi::GaussClusterable::Sub(::kaldi::Clusterable)

type() → str

Calls C++ function ::std::string ::kaldi::GaussClusterable::Type()

write(os:ostream, binary:bool)

Calls C++ function void ::kaldi::GaussClusterable::Write(::std::basic_ostream<char, ::std::char_traits<char> >, bool)

x2_stats() → DoubleSubVector

Calls C++ function ::kaldi::SubVector<double> ::kaldi::GaussClusterable::x2_stats()

x_stats() → DoubleSubVector

Calls C++ function ::kaldi::SubVector<double> ::kaldi::GaussClusterable::x_stats()

class kaldi.tree.Questions

CLIF wrapper for ::kaldi::Questions

get_keys_with_questions() → list<int>

Calls C++ function void ::kaldi::Questions::GetKeysWithQuestions(::std::vector< ::kaldi::EventKeyType>*)

get_questions_of(key:int) → QuestionsForKey

Calls C++ function ::kaldi::QuestionsForKey ::kaldi::Questions::GetQuestionsOf(int)

has_questions_for_key(key:int) → bool

Calls C++ function bool ::kaldi::Questions::HasQuestionsForKey(int)

read(is:istream, binary:bool)

Calls C++ function void ::kaldi::Questions::Read(::std::basic_istream<char, ::std::char_traits<char> >, bool)

set_questions_of(key:int, options_of_key:QuestionsForKey)

Calls C++ function void ::kaldi::Questions::SetQuestionsOf(int, ::kaldi::QuestionsForKey)

write(os:ostream, binary:bool)

Calls C++ function void ::kaldi::Questions::Write(::std::basic_ostream<char, ::std::char_traits<char> >, bool)

class kaldi.tree.QuestionsForKey

CLIF wrapper for ::kaldi::QuestionsForKey

initial_questions

C++ ::std::vector< ::std::vector< ::kaldi::EventValueType> > QuestionsForKey.initial_questions

read(is:istream, binary:bool)

Calls C++ function void ::kaldi::QuestionsForKey::Read(::std::basic_istream<char, ::std::char_traits<char> >, bool)

refine_opts

C++ ::kaldi::RefineClustersOptions QuestionsForKey.refine_opts

write(os:ostream, binary:bool)

Calls C++ function void ::kaldi::QuestionsForKey::Write(::std::basic_ostream<char, ::std::char_traits<char> >, bool)

class kaldi.tree.RefineClustersOptions

CLIF wrapper for ::kaldi::RefineClustersOptions

new(num_iters_in:int, top_n_in:int) → RefineClustersOptions

Calls C++ function std::unique_ptr<::kaldi::RefineClustersOptions> ::kaldi::RefineClustersOptions::RefineClustersOptions(int, int)

num_iters

C++ ::int32 RefineClustersOptions.num_iters

read(is:istream, binary:bool)

Calls C++ function void ::kaldi::RefineClustersOptions::Read(::std::basic_istream<char, ::std::char_traits<char> >, bool)

top_n

C++ ::int32 RefineClustersOptions.top_n

write(os:ostream, binary:bool)

Calls C++ function void ::kaldi::RefineClustersOptions::Write(::std::basic_ostream<char, ::std::char_traits<char> >, bool)

class kaldi.tree.ScalarClusterable

CLIF wrapper for ::kaldi::ScalarClusterable

add(other:Clusterable)

Calls C++ function void ::kaldi::ScalarClusterable::Add(::kaldi::Clusterable)

copy() → Clusterable

Calls C++ function ::kaldi::Clusterable * ::kaldi::ScalarClusterable::Copy()

distance(other:Clusterable) → float

Calls C++ function float ::kaldi::Clusterable::Distance(::kaldi::Clusterable)

info() → str

Calls C++ function ::std::string ::kaldi::ScalarClusterable::Info()

mean() → float

Calls C++ function float ::kaldi::ScalarClusterable::Mean()

new_with_scalar(x:float) → ScalarClusterable

Calls C++ function std::unique_ptr<::kaldi::ScalarClusterable> ::kaldi::ScalarClusterable::ScalarClusterable(float)

normalizer() → float

Calls C++ function float ::kaldi::ScalarClusterable::Normalizer()

objf() → float

Calls C++ function float ::kaldi::ScalarClusterable::Objf()

objf_minus(other:Clusterable) → float

Calls C++ function float ::kaldi::Clusterable::ObjfMinus(::kaldi::Clusterable)

objf_plus(other:Clusterable) → float

Calls C++ function float ::kaldi::Clusterable::ObjfPlus(::kaldi::Clusterable)

read_new(is:istream, binary:bool) → Clusterable

Calls C++ function ::kaldi::Clusterable * ::kaldi::ScalarClusterable::ReadNew(::std::basic_istream<char, ::std::char_traits<char> >, bool)

scale(f:float)

Calls C++ function void ::kaldi::Clusterable::Scale(float)

set_zero()

Calls C++ function void ::kaldi::ScalarClusterable::SetZero()

sub(other:Clusterable)

Calls C++ function void ::kaldi::ScalarClusterable::Sub(::kaldi::Clusterable)

type() → str

Calls C++ function ::std::string ::kaldi::ScalarClusterable::Type()

write(os:ostream, binary:bool)

Calls C++ function void ::kaldi::ScalarClusterable::Write(::std::basic_ostream<char, ::std::char_traits<char> >, bool)

class kaldi.tree.SplitEventMap

CLIF wrapper for ::kaldi::SplitEventMap

check(event:list<tuple<int, int>>)

Calls C++ function void ::kaldi::EventMap::Check(::kaldi::EventType)

copy() → EventMap

Calls C++ function ::kaldi::EventMap * ::kaldi::EventMap::Copy()

copy_with_new_leaves(new_leaves:list<EventMap>) → EventMap

Calls C++ function ::kaldi::EventMap * ::kaldi::SplitEventMap::Copy(::std::vector< ::kaldi::EventMap *>)

get_children() → list<EventMap>

Calls C++ function void ::kaldi::SplitEventMap::GetChildren(::std::vector< ::kaldi::EventMap >)

lookup(event:list<tuple<int, int>>, key:int) -> (success:bool, ans:int)

Calls C++ function bool ::kaldi::EventMap::Lookup(::kaldi::EventType, int, int*)

map(event:list<tuple<int, int>>) -> (success:bool, ans:int)

Calls C++ function bool ::kaldi::SplitEventMap::Map(::kaldi::EventType, int*)

map_values(keys_to_map:set<int>, value_map:dict<int, int>) → EventMap

Calls C++ function ::kaldi::EventMap * ::kaldi::SplitEventMap::MapValues(::std::unordered_set< ::kaldi::EventKeyType>, ::std::unordered_map< ::kaldi::EventValueType, ::kaldi::EventValueType>)

max_result() → int

Calls C++ function int ::kaldi::EventMap::MaxResult()

multi_map(event:list<tuple<int, int>>) → list<int>

Calls C++ function void ::kaldi::SplitEventMap::MultiMap(::kaldi::EventType, ::std::vector< ::kaldi::EventAnswerType>*)

prune() → EventMap

Calls C++ function ::kaldi::EventMap * ::kaldi::SplitEventMap::Prune()

read(is:istream, binary:bool) → SplitEventMap

Calls C++ function ::kaldi::SplitEventMap * ::kaldi::SplitEventMap::Read(::std::basic_istream<char, ::std::char_traits<char> >, bool)

read_event_map(is:istream, binary:bool) → EventMap

Calls C++ function ::kaldi::EventMap * ::kaldi::EventMap::Read(::std::basic_istream<char, ::std::char_traits<char> >, bool)

write(os:ostream, binary:bool)

Calls C++ function void ::kaldi::SplitEventMap::Write(::std::basic_ostream<char, ::std::char_traits<char> >, bool)

write_event_map(os:ostream, binary:bool, emap:EventMap)

Calls C++ function void ::kaldi::EventMap::Write(::std::basic_ostream<char, ::std::char_traits<char> >, bool, ::kaldi::EventMap *)

write_to_stream(os:ostream, binary:bool)

Calls C++ function void ::kaldi::EventMap::Write(::std::basic_ostream<char, ::std::char_traits<char> >, bool)

class kaldi.tree.TableEventMap

CLIF wrapper for ::kaldi::TableEventMap

check(event:list<tuple<int, int>>)

Calls C++ function void ::kaldi::EventMap::Check(::kaldi::EventType)

copy() → EventMap

Calls C++ function ::kaldi::EventMap * ::kaldi::EventMap::Copy()

copy_with_new_leaves(new_leaves:list<EventMap>) → EventMap

Calls C++ function ::kaldi::EventMap * ::kaldi::TableEventMap::Copy(::std::vector< ::kaldi::EventMap *>)

from_val_answer_table(key:int, map_in:dict<int, int>) → TableEventMap

Calls C++ function std::unique_ptr<::kaldi::TableEventMap> ::kaldi::TableEventMap::TableEventMap(int, ::std::map< ::kaldi::EventValueType, ::kaldi::EventAnswerType>)

from_val_map_table(key:int, map_in:dict<int, EventMap>) → TableEventMap

Calls C++ function std::unique_ptr<::kaldi::TableEventMap> ::kaldi::TableEventMap::TableEventMap(int, ::std::map< ::kaldi::EventValueType, ::kaldi::EventMap *>)

get_children() → list<EventMap>

Calls C++ function void ::kaldi::TableEventMap::GetChildren(::std::vector< ::kaldi::EventMap >)

lookup(event:list<tuple<int, int>>, key:int) -> (success:bool, ans:int)

Calls C++ function bool ::kaldi::EventMap::Lookup(::kaldi::EventType, int, int*)

map(event:list<tuple<int, int>>) -> (success:bool, ans:int)

Calls C++ function bool ::kaldi::TableEventMap::Map(::kaldi::EventType, int*)

map_values(keys_to_map:set<int>, value_map:dict<int, int>) → EventMap

Calls C++ function ::kaldi::EventMap * ::kaldi::TableEventMap::MapValues(::std::unordered_set< ::kaldi::EventKeyType>, ::std::unordered_map< ::kaldi::EventValueType, ::kaldi::EventValueType>)

max_result() → int

Calls C++ function int ::kaldi::EventMap::MaxResult()

multi_map(event:list<tuple<int, int>>) → list<int>

Calls C++ function void ::kaldi::TableEventMap::MultiMap(::kaldi::EventType, ::std::vector< ::kaldi::EventAnswerType>*)

prune() → EventMap

Calls C++ function ::kaldi::EventMap * ::kaldi::TableEventMap::Prune()

read(is:istream, binary:bool) → TableEventMap

Calls C++ function ::kaldi::TableEventMap * ::kaldi::TableEventMap::Read(::std::basic_istream<char, ::std::char_traits<char> >, bool)

read_event_map(is:istream, binary:bool) → EventMap

Calls C++ function ::kaldi::EventMap * ::kaldi::EventMap::Read(::std::basic_istream<char, ::std::char_traits<char> >, bool)

write(os:ostream, binary:bool)

Calls C++ function void ::kaldi::TableEventMap::Write(::std::basic_ostream<char, ::std::char_traits<char> >, bool)

write_event_map(os:ostream, binary:bool, emap:EventMap)

Calls C++ function void ::kaldi::EventMap::Write(::std::basic_ostream<char, ::std::char_traits<char> >, bool, ::kaldi::EventMap *)

write_to_stream(os:ostream, binary:bool)

Calls C++ function void ::kaldi::EventMap::Write(::std::basic_ostream<char, ::std::char_traits<char> >, bool)

class kaldi.tree.TreeClusterOptions

CLIF wrapper for ::kaldi::TreeClusterOptions

branch_factor

C++ ::int32 TreeClusterOptions.branch_factor

kmeans_cfg

C++ ::kaldi::ClusterKMeansOptions TreeClusterOptions.kmeans_cfg

thresh

C++ ::kaldi::BaseFloat TreeClusterOptions.thresh

class kaldi.tree.TreeRenderer

CLIF wrapper for ::kaldi::TreeRenderer

render()

Calls C++ function void ::kaldi::TreeRenderer::Render()

render_query(query:list<tuple<int, int>>)

Calls C++ function void ::kaldi::TreeRenderer::RenderQuery(::kaldi::EventType)

class kaldi.tree.VectorClusterable

CLIF wrapper for ::kaldi::VectorClusterable

add(other:Clusterable)

Calls C++ function void ::kaldi::VectorClusterable::Add(::kaldi::Clusterable)

copy() → Clusterable

Calls C++ function ::kaldi::Clusterable * ::kaldi::VectorClusterable::Copy()

distance(other:Clusterable) → float

Calls C++ function float ::kaldi::Clusterable::Distance(::kaldi::Clusterable)

new_with_vector(vector:Vector, weight:float) → VectorClusterable

Calls C++ function std::unique_ptr<::kaldi::VectorClusterable> ::kaldi::VectorClusterable::VectorClusterable(::kaldi::Vector<float>, float)

normalizer() → float

Calls C++ function float ::kaldi::VectorClusterable::Normalizer()

objf() → float

Calls C++ function float ::kaldi::VectorClusterable::Objf()

objf_minus(other:Clusterable) → float

Calls C++ function float ::kaldi::Clusterable::ObjfMinus(::kaldi::Clusterable)

objf_plus(other:Clusterable) → float

Calls C++ function float ::kaldi::Clusterable::ObjfPlus(::kaldi::Clusterable)

read_new(is:istream, binary:bool) → Clusterable

Calls C++ function ::kaldi::Clusterable * ::kaldi::VectorClusterable::ReadNew(::std::basic_istream<char, ::std::char_traits<char> >, bool)

scale(f:float)

Calls C++ function void ::kaldi::VectorClusterable::Scale(float)

set_zero()

Calls C++ function void ::kaldi::VectorClusterable::SetZero()

sub(other:Clusterable)

Calls C++ function void ::kaldi::VectorClusterable::Sub(::kaldi::Clusterable)

type() → str

Calls C++ function ::std::string ::kaldi::VectorClusterable::Type()

write(os:ostream, binary:bool)

Calls C++ function void ::kaldi::VectorClusterable::Write(::std::basic_ostream<char, ::std::char_traits<char> >, bool)

kaldi.tree.add_to_clusters(stats:list<Clusterable>, assignments:list<int>) → list<Clusterable>

Calls C++ function void ::kaldi::AddToClusters(::std::vector< ::kaldi::Clusterable >, ::std::vector< ::int32>, ::std::vector< ::kaldi::Clusterable *>)

kaldi.tree.add_to_clusters_optimized(stats:list<Clusterable>, assignments:list<int>, total:Clusterable) → list<Clusterable>

Calls C++ function void ::kaldi::AddToClustersOptimized(::std::vector< ::kaldi::Clusterable >, ::std::vector< ::int32>, ::kaldi::Clusterable, ::std::vector< ::kaldi::Clusterable *>)

kaldi.tree.build_tree(qopts:Questions, phone_sets:list<list<int>>, phone2num_pdf_classes:list<int>, share_roots:list<bool>, do_split:list<bool>, stats:list<tuple<list<tuple<int, int>>, Clusterable>>, thresh:float, max_leaves:int, cluster_thresh:float, P:int, round_num_leaves:bool=default) → EventMap

Builds a set of decision trees.

This is the normal way to build a set of decision trees. The sets ‘phone_sets’ dictacte how we set up the roots of the decision trees. Each set of phones phone_sets[i] has shared decision-tree roots, and if the corresponding variable share_roots[i] is true, the root will be shared for the different HMM-positions in the phone.

Parameters:
  • qopts (Questions) – Questions options class, contains questions for each key
  • phone_sets (list) – Each element of phone_sets is a set of phones whose roots are shared together
  • phone2num_pdf_classes (list) – A map from phones to the number of pdf_classes in the phone
  • share_roots (list) – A vector the same size as phone_sets; says for each phone set whether the root should be shared among all the pdf-classes or not
  • do_split (list) – A vector the same size as phone_sets; says for each phone set whether decision-tree splitting should be done
  • stats (list) – The statistics used in tree-building
  • thresh (float) – Threshold used in decision-tree splitting or you may use 0 in which case max_leaves becomes the constraint
  • max_leaves (int) – Maximum number of leaves it will create; set this to a large number if you want to specify just thresh
  • cluster_thresh (float) – Threshold for clustering leaves after decision-tree splitting; leaves will be combined if log-likelihood change is less than this.
  • P (int) – The central position of the phone context window
  • round_num_leaves (bool) – If true, then the number of leaves in the final tree is made a multiple of 8. This is done by further clustering the leaves after they are first clustered based on log-likelihood change. (See cluster_thresh above) (default: True).
Returns:

EventMap object that is the tree.

kaldi.tree.build_tree_two_level(qopts:Questions, phone_sets:list<list<int>>, phone2num_pdf_classes:list<int>, share_roots:list<bool>, do_split:list<bool>, stats:list<tuple<list<tuple<int, int>>, Clusterable>>, max_leaves_first:int, max_leaves_second:int, cluster_leaves:bool, P:int) -> (tree:EventMap, leaf_map:list<int>)

Builds a two-level decision tree.

This is useful for example in building tied mixture systems with multiple codebooks.

Parameters:
  • qopts (Questions) – Questions options class, contains questions for each key
  • phone_sets (list) – Each element of phone_sets is a set of phones whose roots are shared together
  • phone2num_pdf_classes (list) – A map from phones to the number of pdf_classes in the phone
  • share_roots (list) – A vector the same size as phone_sets; says for each phone set whether the root should be shared among all the pdf-classes or not
  • do_split (list) – A vector the same size as phone_sets; says for each phone set whether decision-tree splitting should be done
  • stats (list) – The statistics used in tree-building
  • max_leaves_first (int) – Maximum number of leaves it will create in first level
  • max_leaves_second (int) – Maximum number of leaves it will create in second level
  • cluster_leaves (bool) – If true, post-cluster the leaves produced in the second level.
  • P (int) – The central position of the phone context window
Returns:

EventMap object that is the tree leaf_map: Mapping from the leaves of the big tree to the leaves of the little tree

Return type:

tree

kaldi.tree.cluster_bottom_up(points:list<Clusterable>, thresh:float, min_clust:int) -> (objf_change:float, clusters_out:list<Clusterable>, assignments_out:list<int>)

Calls C++ function float ::kaldi::ClusterBottomUp(::std::vector< ::kaldi::Clusterable >, float, int, ::std::vector< ::kaldi::Clusterable *>, ::std::vector< ::int32>*)

kaldi.tree.cluster_bottom_up_compartmentalized(points:list<list<Clusterable>>, thresh:float, min_clust:int) -> (objf_change:float, clusters_out:list<list<Clusterable>>, assignments_out:list<list<int>>)

Calls C++ function float ::kaldi::ClusterBottomUpCompartmentalized(::std::vector< ::std::vector< ::kaldi::Clusterable > >, float, int, ::std::vector< ::std::vector< ::kaldi::Clusterable *> >, ::std::vector< ::std::vector< ::int32> >*)

kaldi.tree.cluster_event_map_get_mapping(e_in:EventMap, stats:list<tuple<list<tuple<int, int>>, Clusterable>>, thresh:float) -> (num_leaves:int, mapping:list<EventMap>)

Clusters the leaves of the EventMap, with ‘thresh’ a delta-likelihood threshold to control how many leaves we combine.

Returns:number of leaves combined mapping: Mapping for leaves
Return type:num_leaves (int)
kaldi.tree.convert_stats(oldN:int, oldP:int, newN:int, newP:int) -> (success:bool, stats:list<tuple<list<tuple<int, int>>, Clusterable>>)

Converts stats from a given context-window (N) and central position (P) to a different N and P

kaldi.tree.find_all_keys(stats:list<tuple<list<tuple<int, int>>, Clusterable>>, keys_type:AllKeysType) → list<int>

Returns the sorted and unique list of all key identities in the stats. If type == ALL_KEYS_INSIST_IDENTICAL, it will insis that this set of keys is the same for all the stats. If type == ALL_KEYS_INTERSECTION, it will return the smallest common set of keys present in the set of stats if type == ALL_KEYS_UNION, it will return the union of all the keys (or undefined if a key is not present)

kaldi.tree.gen_rand_stats(dim:int, num_stats:int, N:int, P:int, phone_ids:list<int>, hmm_lengths:list<int>, is_ctx_dep:list<bool>, ensure_all_phones_covered:bool) → list<tuple<list<tuple<int, int>>, Clusterable>>

Generates random statistics of the form used by build_tree.

It tries to do so in such a way that they mimic “real” stats. The event keys and their corresponding values are:

key value
-1 == PDF_CLASS pdf-class
0 phone-id of left-most context phone
1 phone-id of one-from-left-most context phone
P - 1 phone-id of central phone
N - 1 phone-id of right-most context phone.
Parameters:
  • dim (int) – dimension of features
  • num_stats (int) – approximate number of separate phones-in-context wanted
  • N (int) – context-size
  • P (int) – central-phone position
  • phone_ids (list) – ids of phones
  • hmm_lengths (list) – lenghts of hmm for phone
  • is_ctx_dep (list) – boolean array whether each phone is context-dependant
  • ensure_all_phones_covered (bool) – If true, ensures that every phone is seen at least once in the central position
Returns:

Statistics of the form used by BuildTree

kaldi.tree.get_tree_structure(map:EventMap) -> (has_tree_structure:bool, num_leaves:int, parents:list<int>)

Calls C++ function bool ::kaldi::GetTreeStructure(::kaldi::EventMap, int*, ::std::vector< ::int32>*)

kaldi.tree.make_event_pair(k:int, v:int) → tuple<int, int>

Calls C++ function ::std::pair< ::kaldi::EventKeyType, ::kaldi::EventValueType> ::kaldi::MakeEventPair(int, int)

kaldi.tree.map_event_map_leaves(e_in:EventMap, mapping:list<int>) → EventMap

Remaps the event-map leaves using this mapping indexed by number of leaf

kaldi.tree.monophone_context_dependency(phones:list<int>, phone2num_pdf_classes:list<int>) → ContextDependency

Returns a new ContextDependency object for a monophone system.

kaldi.tree.monophone_context_dependency_shared(phone_classes:list<list<int>>, phone2num_pdf_classes:list<int>) → ContextDependency

Returns a new ContextDependency object for a monophone system with shared PDFs.

kaldi.tree.objf_given_map(stats_in:list<tuple<list<tuple<int, int>>, Clusterable>>, e:EventMap) → float

Cluster the stats given the event map return the total objf given those clusters

kaldi.tree.possible_values(key:int, stats:list<tuple<list<tuple<int, int>>, Clusterable>>) -> (key_found:bool, ans:list<int>)

Convenienve function to work out possible values of the phones from just the stats.

Returns:True if key was always defined inside the stats.
kaldi.tree.read_build_tree_stats(is:istream, binary:bool, example:Clusterable) → list<tuple<list<tuple<int, int>>, Clusterable>>

Reads BuildTreeStatsType object. The ‘example’ argument must be of the same type as the stats on disk, and is needed to access to the correct read function

kaldi.tree.read_event_type(is:istream, binary:bool) → list<tuple<int, int>>

Calls C++ function void ::kaldi::ReadEventType(::std::basic_istream<char, ::std::char_traits<char> >, bool, ::kaldi::EventType*)

kaldi.tree.read_roots_file(is:istream) -> (phone_sets:list<list<int>>, is_shared_root:list<bool>, is_split_root:list<bool>)

Reads roots from file.

kaldi.tree.read_symbol_table_as_integers(filename:str, include_eps:bool) → list<int>

Reads a symbol table, discards the symbols and returns the indexes.

kaldi.tree.split_decision_tree(orig:EventMap, stats:list<tuple<list<tuple<int, int>>, Clusterable>>, qcfg:Questions, thresh:float, max_leaves:int) -> (out_tree:EventMap, num_leaves:int, objf_impr_out:float, smallest_split_change_out:float)

Calls C++ function ::kaldi::EventMap * ::kaldi::SplitDecisionTree(::kaldi::EventMap, ::kaldi::BuildTreeStatsType, ::kaldi::Questions, float, int, int*, float*, float*)

kaldi.tree.split_stats_by_key(stats_in:list<tuple<list<tuple<int, int>>, Clusterable>>, key:int) → list<list<tuple<list<tuple<int, int>>, Clusterable>>>

Splits stats up according to the value of a particular key, which must be always defined and nonnegative.

kaldi.tree.split_stats_by_map(stats_in:list<tuple<list<tuple<int, int>>, Clusterable>>, e:EventMap) → list<list<tuple<list<tuple<int, int>>, Clusterable>>>

Splits stats according to the EventMap, indexing them at output by the leaf type.

kaldi.tree.sum_clusterable(vec:list<Clusterable>) → Clusterable

Calls C++ function ::kaldi::Clusterable * ::kaldi::SumClusterable(::std::vector< ::kaldi::Clusterable *>)

kaldi.tree.sum_clusterable_normalizer(vec:list<Clusterable>) → float

Calls C++ function float ::kaldi::SumClusterableNormalizer(::std::vector< ::kaldi::Clusterable *>)

kaldi.tree.sum_clusterable_objf(vec:list<Clusterable>) → float

Calls C++ function float ::kaldi::SumClusterableObjf(::std::vector< ::kaldi::Clusterable *>)

kaldi.tree.sum_normalizer(stats_in:list<tuple<list<tuple<int, int>>, Clusterable>>) → float

Sums the normalizer over the stats

kaldi.tree.sum_objf(stats_in:list<tuple<list<tuple<int, int>>, Clusterable>>) → float

Sums the objective function over the stats

kaldi.tree.sum_stats(stats_in:list<tuple<list<tuple<int, int>>, Clusterable>>) → Clusterable

Sums stats

kaldi.tree.sum_stats_vec(stats_in:list<list<tuple<list<tuple<int, int>>, Clusterable>>>) → list<Clusterable>

Sum a vector of stats

kaldi.tree.write_build_tree_stats(os:ostream, binary:bool, stats:list<tuple<list<tuple<int, int>>, Clusterable>>)

Writes BuildTreeStatsType. Works even if the pointers are NULL

kaldi.tree.write_event_type(os:ostream, binary:bool, vec:list<tuple<int, int>>)

Calls C++ function void ::kaldi::WriteEventType(::std::basic_ostream<char, ::std::char_traits<char> >, bool, ::kaldi::EventType)