Skip to content

Minor changes required for nnet3 sequence training#560

Merged
danpovey merged 1 commit intokaldi-asr:chainfrom
vimalmanohar:sequence_changes
Mar 7, 2016
Merged

Minor changes required for nnet3 sequence training#560
danpovey merged 1 commit intokaldi-asr:chainfrom
vimalmanohar:sequence_changes

Conversation

@vimalmanohar
Copy link
Contributor

No description provided.

@danpovey
Copy link
Contributor

danpovey commented Mar 6, 2016

Thanks- will try to review soon. @vijayaditya, if you have time please take a look.

@vijayaditya
Copy link
Contributor

OK, I will work on this after the ivector PR from Yiming.

--VIjay

On Sat, Mar 5, 2016 at 9:45 PM, Daniel Povey notifications@github.com
wrote:

Thanks- will try to review soon. @vijayaditya
https://github.com/vijayaditya, if you have time please take a look.


Reply to this email directly or view it on GitHub
#560 (comment).

@vimalmanohar
Copy link
Contributor Author

Note: This is not the full set of changes. There is a lot of codes and scripts, which is beyond what the github diff allows to view. So I am committing them in small chunks that would be easier to look at. This is first set of commits.

@vimalmanohar
Copy link
Contributor Author

I can push the next set of commits once this is merged.

// negated costs. Requires that lat be topologically sorted. This code
// will work for either CompactLattice or Latice.
template<typename LatticeType>
double ComputeLatticeAlphasAndBetas(const LatticeType &lat,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vimal, it's not good for compilation speed to define this in the header.
Just declare it in the header, and in the .cc file, define it and instantiate it for float and double.

@danpovey
Copy link
Contributor

danpovey commented Mar 7, 2016

OK, done. Please merge or rebase.

@vimalmanohar vimalmanohar force-pushed the sequence_changes branch 2 times, most recently from cb187d9 to 541e4ae Compare March 7, 2016 00:20
@vimalmanohar
Copy link
Contributor Author

I have changed the functions to use SetUnderlyingLearningRate

if (uc == NULL)
KALDI_ERR << "Updatable component does not inherit from class "
"UpdatableComponent; change this code.";
uc->SetUnderlyingLearningRate(uc->LearningRate() * learning_rate_scale);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you actually want to use SetActualLearningRate() here.

@vimalmanohar
Copy link
Contributor Author

I made the change.

vector<double> *beta);


static inline double LogAddOrMax(bool viterbi, double a, double b) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you still need this function to be in the header?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its a small function that can be inlined. If it is moved to .cc file, it
cannot be inlined.

On Sun, Mar 6, 2016 at 8:19 PM Daniel Povey notifications@github.com
wrote:

In src/lat/lattice-functions.h
#560 (comment):

@@ -74,6 +74,26 @@ bool ComputeCompactLatticeAlphas(const CompactLattice &lat,
bool ComputeCompactLatticeBetas(const CompactLattice &lat,
vector *beta);

+static inline double LogAddOrMax(bool viterbi, double a, double b) {

do you still need this function to be in the header?


Reply to this email directly or view it on GitHub
https://github.com/kaldi-asr/kaldi/pull/560/files#r55153738.

Vimal Manohar
PhD Student
Electrical & Computer Engineering
Johns Hopkins University

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so you are going to call it from some other code you have written?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also if you are going to leave it in the header you should take away the 'static'.

@vimalmanohar
Copy link
Contributor Author

It seems there was only function that used it, which is not back in the .cc file. So I moved it to the .cc file.

return true;
}

static inline double LogAddOrMax(bool viterbi, double a, double b) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, you've now just moved this code around. could you revert this file?

@danpovey
Copy link
Contributor

danpovey commented Mar 7, 2016

and please squash your commits.

@vimalmanohar
Copy link
Contributor Author

Done

bool binary,
Vector<BaseFloat> *vec);

void RoundUpNumFrames(int32 frame_subsampling_factor,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should document this declaration.

@vimalmanohar
Copy link
Contributor Author

Fixed

}
};

/// Comparator object that does comparison on a different
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comparator is not very well explained.
However, I think I see what you are trying to do here-- it would be better, instead of using this comparator, to instead sort a vector of pairs, where the 1st of each pair is the thing you want to sort on, and the 2nd is the index that you want to sort.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where it is used:
https://github.com/vimalmanohar/kaldi/blob/sequence_clean/src/nnet3/discriminative-supervision.cc#L542
Would I have to write a similar comparator to sort the vector of pairs?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No you wouldn't have to write any comparator, the default one works.
I'm saying a make vector of pairs

(state-time, state-index)

and sort it. you don't even need stable_sort, since if state_time is the
same, the state_index gets used instead.

On Sun, Mar 6, 2016 at 11:27 PM, Vimal Manohar notifications@github.com
wrote:

In src/util/stl-utils.h
#560 (comment):

@@ -292,6 +292,29 @@ struct CompareFirstMemberOfPair {
}
};

+/// Comparator object that does comparison on a different

This is where it is used:

https://github.com/vimalmanohar/kaldi/blob/sequence_clean/src/nnet3/discriminative-supervision.cc#L542
Would I have to write a similar comparator to sort the vector of pairs?


Reply to this email directly or view it on GitHub
https://github.com/kaldi-asr/kaldi/pull/560/files#r55161297.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I removed the comparator from stl-utils.h. I will modify the sort code
to use pairs.

On Sun, Mar 6, 2016 at 11:36 PM Daniel Povey notifications@github.com
wrote:

In src/util/stl-utils.h
#560 (comment):

@@ -292,6 +292,29 @@ struct CompareFirstMemberOfPair {
}
};

+/// Comparator object that does comparison on a different

No you wouldn't have to write any comparator, the default one works. I'm
saying a make vector of pairs (state-time, state-index) and sort it. you
don't even need stable_sort, since if state_time is the same, the
state_index gets used instead.
… <#msg-f:1528116455082592170_>
On Sun, Mar 6, 2016 at 11:27 PM, Vimal Manohar notifications@github.com
wrote: In src/util/stl-utils.h <#560 (comment)
https://github.com/kaldi-asr/kaldi/pull/560#discussion_r55161297>: > @@
-292,6 +292,29 @@ struct CompareFirstMemberOfPair { > } > }; > > +///
Comparator object that does comparison on a different This is where it is
used:
https://github.com/vimalmanohar/kaldi/blob/sequence_clean/src/nnet3/discriminative-supervision.cc#L542
Would I have to write a similar comparator to sort the vector of pairs? —
Reply to this email directly or view it on GitHub <
https://github.com/kaldi-asr/kaldi/pull/560/files#r55161297>.


Reply to this email directly or view it on GitHub
https://github.com/kaldi-asr/kaldi/pull/560/files#r55161622.

Vimal Manohar
PhD Student
Electrical & Computer Engineering
Johns Hopkins University

@danpovey
Copy link
Contributor

danpovey commented Mar 7, 2016

OK, thanks! Merging.

danpovey added a commit that referenced this pull request Mar 7, 2016
Minor changes required for nnet3 sequence training
@danpovey danpovey merged commit 2c9bff8 into kaldi-asr:chain Mar 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants