Skip to content

Commit

Permalink
trunk: some minor fixes
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.code.sf.net/p/kaldi/code/trunk@4502 5e6a8d80-dfce-4ca6-a32a-6e07a63d50c8
  • Loading branch information
danpovey committed Oct 4, 2014
1 parent 6becaf2 commit 2aa9af8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/bin/analyze-counts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ int main(int argc, char *argv[]) {
typedef kaldi::uint64 uint64;
try {
const char *usage =
"Counts element frequencies from integer vector table.\n"
"(eg. for example to get pdf-counts to estimate DNN-output priros, or data analysis)\n"
"Computes element counts from integer vector table.\n"
"(e.g. for example to get pdf-counts to estimate DNN-output priors, for data analysis)\n"
"Verbosity : level 1 => print frequencies and histogram\n"
"\n"
"Usage: analyze-counts [options] <alignments-rspecifier> <counts-wxfilname>\n"
Expand Down Expand Up @@ -86,7 +86,7 @@ int main(int argc, char *argv[]) {
for(size_t i = 0; i < counts.size(); i++) {
if(counts_nozero[i] == 0) {
KALDI_WARN << "Zero count for element " << i << ", force setting to one."
<< " This avoids divide-by-zero when used counts used in decoding.";
<< " This avoids divide-by-zero when we use the counts in decoding.";
counts_nozero[i]++;
}
}
Expand Down
12 changes: 9 additions & 3 deletions src/nnet2/nnet-nnet.cc
Original file line number Diff line number Diff line change
Expand Up @@ -708,14 +708,20 @@ Nnet *GenRandomNnet(int32 input_dim,
return ans;
}

int32 Nnet::FirstUpdatableComponent() const {
for (int32 i = 0; i < NumComponents(); i++) {
if (dynamic_cast<UpdatableComponent*>(components_[i]) != NULL)
return i;
}
return NumComponents();
}


int32 Nnet::LastUpdatableComponent() const {
int32 last_updatable_component = NumComponents();
for (int32 i = NumComponents() - 1; i >= 0; i--)
if (dynamic_cast<UpdatableComponent*>(components_[i]) != NULL)
last_updatable_component = i;
return last_updatable_component;
return i;
return -1;
}

} // namespace nnet2
Expand Down
9 changes: 6 additions & 3 deletions src/nnet2/nnet-nnet.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,12 @@ class Nnet {
/// this neural net, leaving everything else fixed.
void CopyStatsFrom(const Nnet &nnet);


/// Returns the index of the last component which is updatable,
/// or NumComponents() if none are updatable.
/// Returns the index of the lowest-numbered component which is updatable, or
/// NumComponents() if none are updatable.
int32 FirstUpdatableComponent() const;

/// Returns the index of the highest-numbered component which is updatable, or
/// -1 if none are updatable.
int32 LastUpdatableComponent() const;

/// Returns the number of updatable components.
Expand Down
2 changes: 1 addition & 1 deletion src/nnet2/nnet-update.cc
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ double NnetUpdater::ComputeTotAccuracy(
void NnetUpdater::Backprop(CuMatrix<BaseFloat> *deriv) const {
// We assume ComputeObjfAndDeriv has already been called.
for (int32 c = nnet_.NumComponents() - 1;
c >= nnet_.LastUpdatableComponent(); c--) {
c >= nnet_.FirstUpdatableComponent(); c--) {
const Component &component = nnet_.GetComponent(c);
Component *component_to_update = (nnet_to_update_ == NULL ? NULL :
&(nnet_to_update_->GetComponent(c)));
Expand Down

0 comments on commit 2aa9af8

Please sign in to comment.