Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Dropout component in netted to be used ephemeral connection. #1032

Merged
merged 1 commit into from
Oct 4, 2016

Conversation

pegahgh
Copy link
Contributor

@pegahgh pegahgh commented Sep 17, 2016

No description provided.

public:
void Init(int32 dim, BaseFloat dropout_proportion = 0.0);

DropoutComponent(int32 dim, BaseFloat dp = 0.0) { Init(dim, dp); }
Copy link
Contributor

Choose a reason for hiding this comment

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

dp is a too-short name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!


DropoutComponent(int32 dim, BaseFloat dp = 0.0) { Init(dim, dp); }

DropoutComponent():dim_(0), dropout_proportion_(0.0) { }
Copy link
Contributor

Choose a reason for hiding this comment

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

space after colon

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@danpovey
Copy link
Contributor

You haven't added DropoutComponent to the components used in testing. So it's not being tested. It's not clear that the tests would even work without modification- it might be necessary to reset the random number generators for some of the comparisons.

@danpovey
Copy link
Contributor

Also we need a way to set the dropout-proportions via the command line.
You could add a function
SetDropoutProportion()
in nnet-nnet.h, and add an option --set-dropout-proportion to nnet3-copy.

On Fri, Sep 16, 2016 at 6:10 PM, pegahgh notifications@github.com wrote:


You can view, comment on, or merge this pull request online at:

#1032
Commit Summary

  • added DropoutComponent to nnet3 for ephemeral connection test.
  • added DropoutComponent to nnet3 for ephemeral connection test.
  • fixed small issues.
  • fixed small issues.
  • fixed small issues.
  • fixed small issues.

File Changes

Patch Links:


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#1032, or mute the thread
https://github.com/notifications/unsubscribe-auth/ADJVu0b-Jcx6xMcRhC52NcNWzi7AiAlAks5qqz4CgaJpZM4J_d_R
.

@pegahgh
Copy link
Contributor Author

pegahgh commented Sep 17, 2016

  1. I added Dropout to the components in the testing
  2. I reset random generator.
  3. I added the --set-dropout-proportion via command line in nnet3-copy
  4. I added SetDropoutProportion in nnet-utils.*
    Done all changes. I added SetDropoutProportion, RemoveDropout and modified test to reset seed for dropout component test.
  5. Added RemoveDropout in nnet-nnet.h

@danpovey
Copy link
Contributor

Please push your changes, and also rebase to clean up the commit history- I prefer just one commit.

@pegahgh
Copy link
Contributor Author

pegahgh commented Sep 18, 2016

I pushed the new changes after rebasing (Just single commit!!!!)

On Sep 18, 2016 3:13 PM, "Daniel Povey" notifications@github.com wrote:

Please push your changes, and also rebase to clean up the commit history-
I prefer just one commit.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#1032 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AI-PtM4Tu185pRezQbwhK__Q9DQr2Lczks5qrY1DgaJpZM4J_d_R
.

@pegahgh pegahgh force-pushed the ladnn-droput branch 2 times, most recently from 7e503a2 to b42f818 Compare September 19, 2016 00:19
@danpovey
Copy link
Contributor

@pegahgh, please go through all comments on this page and make sure you have addressed them-- same for the other PR you have. There are outstanding comments where the issue is not fixed.

@pegahgh
Copy link
Contributor Author

pegahgh commented Sep 21, 2016

@danpovey I reviewed all comments on this page and I found all the issues fixed. Maybe the issue is that I did rebase and the fixed version of codes don't appear in conversation!
Did you check the files changed directly or you just checked the conversation?

@danpovey
Copy link
Contributor

Oh-- I just checked the conversation, it seems the files were updated if I click on the right tab.
I think it used to be the case that github would say "danpovey commented on an outdated commit" if the lines of code that I commented on had changed, but it didn't say that.

@pegahgh
Copy link
Contributor Author

pegahgh commented Sep 21, 2016

Maybe the reason is that I commented on conversation after committing changes, so it is not out-dated!!

}
}

void Nnet::RemoveDropout() {
Copy link
Contributor

Choose a reason for hiding this comment

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

this function would not work.. nnet3 isn't just a linear sequence of components. Just remove this function for now.

public:
// This function is required in testing code and in other places we need
// consistency in the random number generation (e.g. when optimizing
// validation-set performance), but check where else we call sRand(). You'll
Copy link
Contributor

Choose a reason for hiding this comment

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

should be srand not sRand. this appears elsewhere too, I think.

@pegahgh
Copy link
Contributor Author

pegahgh commented Sep 21, 2016

@danpovey I can easily test ephemeral connection using dropout on TDNN!
Probably it would be better idea, if Yiming check this connection on LSTM, since he is more expert in that area!

@danpovey
Copy link
Contributor

Before that can be done, I need to do some coding to make it possible to remove the dropout components. I want to make this part of a more general framework for editing nnets, that will also be used in your multilingual stuff. So I think it might be better to wait a few days. But I guess if you want to start work on the scripting components, and you're not otherwise busy, it's OK with me.

// effective.

// Removes all dropout components from network, which can be used during test time.
void RemoveDropout();
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please take out this RemoveDropout() function?
I have been thinking about it, and I think the best way to do this would be at the config level: a file "remove-ephemeral-connections.config" would be created that modifies the nodes that sum over the real and emphemeral connections by replacing expressions like Add(real_node, ephmeral_node) with real_node.
Then we can clean up the model by taking out orphan nodes and components; I have written the code for this and will commit it at some point in future.

@pegahgh pegahgh force-pushed the ladnn-droput branch 3 times, most recently from 0d37b1a to e866023 Compare September 25, 2016 17:54
@pegahgh
Copy link
Contributor Author

pegahgh commented Sep 25, 2016

Removed RemoveDropout function.


KALDI_ASSERT(in_value.NumRows() == out_deriv.NumRows() &&
in_value.NumCols() == out_deriv.NumCols());
in_deriv->AddMatMatDivMat(out_deriv, out_value, in_value);
Copy link
Contributor

Choose a reason for hiding this comment

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

since this is adding, you should include kBackpropAdds in the Properties().
You should also add the kLinearInInput flag.

@@ -143,7 +143,9 @@ void DropoutComponent::Backprop(const std::string &debug_info,

KALDI_ASSERT(in_value.NumRows() == out_deriv.NumRows() &&
in_value.NumCols() == out_deriv.NumCols());
in_deriv->AddMatMatDivMat(out_deriv, out_value, in_value);
CuMatrix<BaseFloat> in_deriv_inplace(in_deriv->NumRows(), in_deriv->NumCols());
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure why you made these changes? This shouldn't have been necessary. Let me know if there was a test failure when you added the flag, the cause might be something else.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added kBackpropAdds and kLinearInInput to Properties().
It seems AddMatMatDivMat method doesn't add this to its output, which is against what we expect in most of AddMat functions.
I didn't modify this function and I supported kBackpropAdds in backprop by having temporary matrix and adding it to in_deriv!

we may need to modify AddMatMatDivMat method to do *this += a * b / c !!

@danpovey
Copy link
Contributor

OK, I see the problem.
The issue is that the name of the function AddMatMatDivMat is out of sync with what the function actually does: it doesn't add to the matrix, it sets it. It should be renamed to SetMatMatDivMat.
And you can remove the flag kBackpropAdds, add the flag kBackpropInPlace, and revert the code changes in the Backprop function.

@pegahgh
Copy link
Contributor Author

pegahgh commented Sep 26, 2016

Should I rename the function in this PR, or you plan to do this later?

@danpovey
Copy link
Contributor

rename it

On Sun, Sep 25, 2016 at 8:17 PM, pegahgh notifications@github.com wrote:

Should I rename the function in this PR, or you plan to do this later?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#1032 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/ADJVu7YYK5p26PgWOWJWN4Y-hbmvykZpks5qtw8CgaJpZM4J_d_R
.

@@ -989,7 +989,7 @@ void CuMatrixBase<Real>::AddMatBlocks(Real alpha, const CuMatrixBase<Real> &A,
/// dst = a * b / c (by element; when c = 0, dst = a)
/// dst can be an alias of a, b or c safely and get expected result.
template<typename Real>
void CuMatrixBase<Real>::AddMatMatDivMat(const CuMatrixBase<Real> &A,
void CuMatrixBase<Real>::SetMatMatDivMat(const CuMatrixBase<Real> &A,
Copy link
Contributor

Choose a reason for hiding this comment

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

If we don't do this now we'll forget about it-- can you also please change the kernel names to remove the add and make it set ?

return stream.str();
}

void DropoutComponent::Propagate(const ComponentPrecomputedIndexes *indexes,
Copy link
Contributor

Choose a reason for hiding this comment

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

In this implementation of drop-out you are using a different mask for each sample in the minibatch. I don't know if other versions of drop-out do this (can anyone clarify ?). If they don't you should probably highlight this in the comments. I think this version is better.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi Vijay, I am not aware of a paper where would be mentioned that the same dropout mask should be used for all the samples within the mini-batch. Yes, I am assuming that all the samples are independent, having different topologies of NN, so each sample has a different mask. Has anybody tried having it the other way? Thanks!
K.

@danpovey
Copy link
Contributor

Karel's did. I expect they probably normally do it that way but don't know
for sure.

On Tue, Sep 27, 2016 at 11:50 PM, Vijayaditya Peddinti <
notifications@github.com> wrote:

@vijayaditya commented on this pull request.

In src/nnet3/nnet-simple-component.cc
#1032 (review):

  • cfl->GetValue("dropout-proportion", &dropout_proportion);
  • if (!ok || cfl->HasUnusedValues() || dim <= 0 ||
  •  dropout_proportion < 0.0 || dropout_proportion > 1.0)
    
  • KALDI_ERR << "Invalid initializer for layer of type "
  •          << Type() << ": \"" << cfl->WholeLine() << "\"";
    
  • Init(dim, dropout_proportion);
    +}

+std::string DropoutComponent::Info() const {

  • std::ostringstream stream;
  • stream << Type() << ", dim = " << dim_
  •     << ", dropout-proportion = " << dropout_proportion_;
    
  • return stream.str();
    +}

+void DropoutComponent::Propagate(const ComponentPrecomputedIndexes *indexes,

In this implementation of drop-out you are using a different mask for each
sample in the minibatch. I don't know if other versions of drop-out do this
(can anyone clarify ?). If they don't you should probably highlight this in
the comments. I think this version is better.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#1032 (review),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADJVu9RSxmj9aSOw-32nEOTA0iyjzSc0ks5queQfgaJpZM4J_d_R
.

@vijayaditya
Copy link
Contributor

@pegahgh I was curious about the expected completion date for this component.

@danpovey
Copy link
Contributor

The only thing that has to be done is to rename some kernels.
(Also, to resolve some conflicts).

@pegahgh
Copy link
Contributor Author

pegahgh commented Sep 30, 2016

oh! I will rename them right now!

@pegahgh
Copy link
Contributor Author

pegahgh commented Sep 30, 2016

Done!

// random components. You must also set srand() for this to be
// effective.

>>>>>>> 05d2e30... added DropoutComponent to nnet3 for ephemeral connection.
Copy link
Contributor

Choose a reason for hiding this comment

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

looks like you did not completely resolve these conflicts!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh sorry! fixed!

@@ -1219,6 +1219,15 @@ static void GenerateRandomComponentConfig(std::string *component_type,
os << " self-repair-target=" << RandUniform();
break;
}
<<<<<<< HEAD
=======
Copy link
Contributor

Choose a reason for hiding this comment

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

and here.. check for === via grep et.

@danpovey
Copy link
Contributor

danpovey commented Oct 1, 2016

Also, please make sure this compiles with GPU... if you had compiled, you wouldn't have missed these errors.

@pegahgh
Copy link
Contributor Author

pegahgh commented Oct 3, 2016

fixed type and it compiled with GPU!

@danpovey danpovey merged commit 4b5eed2 into kaldi-asr:master Oct 4, 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.

4 participants