nnet-graph.h
Go to the documentation of this file.
1 // nnet3/nnet-graph.h
2 
3 // Copyright 2012-2015 Johns Hopkins University (author: Daniel Povey)
4 // 2015 Guoguo Chen
5 
6 // See ../../COPYING for clarification regarding multiple authors
7 //
8 // Licensed under the Apache License, Version 2.0 (the "License");
9 // you may not use this file except in compliance with the License.
10 // You may obtain a copy of the License at
11 //
12 // http://www.apache.org/licenses/LICENSE-2.0
13 //
14 // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
16 // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
17 // MERCHANTABLITY OR NON-INFRINGEMENT.
18 // See the Apache 2 License for the specific language governing permissions and
19 // limitations under the License.
20 
21 #ifndef KALDI_NNET3_NNET_GRAPH_H_
22 #define KALDI_NNET3_NNET_GRAPH_H_
23 
24 #include "nnet3/nnet-nnet.h"
25 
26 
27 namespace kaldi {
28 namespace nnet3 {
29 
39 std::string PrintGraphToString(const std::vector<std::vector<int32> > &graph);
42 
50 void NnetToDirectedGraph(const Nnet &nnet,
51  std::vector<std::vector<int32> > *graph);
52 
53 
60 void FindSccs(const std::vector<std::vector<int32> > &graph,
61  std::vector<std::vector<int32> > *sccs);
62 
63 
67 bool GraphHasCycles(const std::vector<std::vector<int32> > &graph);
68 
69 
72 void MakeSccGraph(const std::vector<std::vector<int32> > &graph,
73  const std::vector<std::vector<int32> > &sccs,
74  std::vector<std::vector<int32> > *scc_graph);
75 
83 void ComputeTopSortOrder(const std::vector<std::vector<int32> > &graph,
84  std::vector<int32> *node_to_order);
85 
86 
88 void ComputeGraphTranspose(const std::vector<std::vector<int32> > &graph,
89  std::vector<std::vector<int32> > *graph_transpose);
90 
101 void ComputeNnetComputationEpochs(const Nnet &nnet,
102  std::vector<int32> *node_to_epoch);
103 
104 
105 } // namespace nnet3
106 } // namespace kaldi
107 
108 #endif
void NnetToDirectedGraph(const Nnet &nnet, std::vector< std::vector< int32 > > *graph)
This function takes an nnet and turns it to a directed graph on nodes.
Definition: nnet-graph.cc:30
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
void ComputeGraphTranspose(const std::vector< std::vector< int32 > > &graph, std::vector< std::vector< int32 > > *graph_transpose)
Outputs a graph in which the order of arcs is reversed.
Definition: nnet-graph.cc:63
bool GraphHasCycles(const std::vector< std::vector< int32 > > &graph)
This function returns &#39;true&#39; if the graph represented in &#39;graph&#39; contains cycles (including cycles wh...
Definition: nnet-graph.cc:300
void ComputeTopSortOrder(const std::vector< std::vector< int32 > > &graph, std::vector< int32 > *node_to_order)
Given an acyclic graph (where each std::vector<int32> is a list of destination-nodes of arcs coming f...
Definition: nnet-graph.cc:223
void ComputeNnetComputationEpochs(const Nnet &nnet, std::vector< int32 > *node_to_epoch)
This function computes the order in which we need to compute each node in the graph, where each node-index n maps to an epoch-index t = 0, 1, ...
Definition: nnet-graph.cc:265
void FindSccs(const std::vector< std::vector< int32 > > &graph, std::vector< std::vector< int32 > > *sccs)
Given a directed graph (where each std::vector<int32> is a list of destination-nodes of arcs coming f...
Definition: nnet-graph.cc:156
void MakeSccGraph(const std::vector< std::vector< int32 > > &graph, const std::vector< std::vector< int32 > > &sccs, std::vector< std::vector< int32 > > *scc_graph)
Given a list of sccs of a graph (e.g.
Definition: nnet-graph.cc:164
std::string PrintGraphToString(const std::vector< std::vector< int32 > > &graph)
Prints a graph to a string in a pretty way for human readability, e.g.
Definition: nnet-graph.cc:248