-
Notifications
You must be signed in to change notification settings - Fork 5.4k
support load kaldi model in python #3976
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5a40d73
support load kaldi model in python
fanlu 422d99e
add some component
fanlu c7e9f4e
split one file to multi component wrap files
fanlu 6af774b
fix some bugs and add test mdl
fanlu 3987407
add testmode func in batchnorm pybind
fanlu 946c81f
change StatsSum StatsSumsq to Mean Var
fanlu 11429f2
make const
fanlu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| // pybind/nnet3/nnet_nnet_pybind.cc | ||
|
|
||
| // Copyright 2019 JD AI, Beijing, China (author: Lu Fan) | ||
fanlu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| // See ../../../COPYING for clarification regarding multiple authors | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED | ||
| // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
| // MERCHANTABLITY OR NON-INFRINGEMENT. | ||
| // See the Apache 2 License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #include "nnet3/nnet_nnet_pybind.h" | ||
|
|
||
| #include "nnet3/nnet-nnet.h" | ||
| #include "nnet3/nnet-component-itf.h" | ||
|
|
||
| using namespace kaldi; | ||
| using namespace kaldi::nnet3; | ||
|
|
||
| void pybind_nnet_nnet(py::module& m) { | ||
| using PyClass = Nnet; | ||
| py::class_<PyClass>( | ||
| m, "Nnet", | ||
| "This function can be used either to initialize a new Nnet from a config" | ||
| "file, or to add to an existing Nnet, possibly replacing certain parts of" | ||
| "it. It will die with error if something went wrong." | ||
| "Also see the function ReadEditConfig() in nnet-utils.h (it's made a" | ||
| "non-member because it doesn't need special access)." | ||
| ) | ||
| .def(py::init<>()) | ||
| .def("Read", &PyClass::Read, py::arg("is"), py::arg("binary")) | ||
| .def("GetComponentNames", &PyClass::GetComponentNames, | ||
| "returns vector of component names (needed by some parsing code, for instance).", | ||
| py::return_value_policy::reference) | ||
| .def("GetComponentName", &PyClass::GetComponentName, py::arg("component_index")) | ||
| .def("Info", &PyClass::Info) | ||
fanlu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| .def("NumComponents", &PyClass::NumComponents) | ||
| .def("NumNodes", &PyClass::NumNodes) | ||
| // .def("GetComponent", &PyClass::GetComponent, py::arg("c")) | ||
| ; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| // pybind/nnet3/nnet_nnet_pybind.h | ||
|
|
||
| // Copyright 2020 JD AI, Beijing, China (author: Lu Fan) | ||
|
|
||
| // See ../../../COPYING for clarification regarding multiple authors | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED | ||
| // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
| // MERCHANTABLITY OR NON-INFRINGEMENT. | ||
| // See the Apache 2 License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #ifndef KALDI_PYBIND_NNET3_NNET_NNET_PYBIND_H_ | ||
| #define KALDI_PYBIND_NNET3_NNET_NNET_PYBIND_H_ | ||
|
|
||
| #include "pybind/kaldi_pybind.h" | ||
|
|
||
| void pybind_nnet_nnet(py::module& m); | ||
|
|
||
| #endif // KALDI_PYBIND_NNET3_NNET_NNET_PYBIND_H_ |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.