Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
kaldi-commonvoice
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Simon Will
kaldi-commonvoice
Commits
9be984c6
Commit
9be984c6
authored
9 years ago
by
Dan Povey
Browse files
Options
Downloads
Patches
Plain Diff
Adding .cc file nnet-ctc-example.cc
parent
7f8fb43e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/nnet3/nnet-ctc-example.cc
+120
-0
120 additions, 0 deletions
src/nnet3/nnet-ctc-example.cc
with
120 additions
and
0 deletions
src/nnet3/nnet-ctc-example.cc
0 → 100644
+
120
−
0
View file @
9be984c6
// nnet3/nnet-ctcexample.cc
// Copyright 2015 Johns Hopkins University (author: Daniel Povey)
// 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-ctc-example.h"
namespace
kaldi
{
namespace
nnet3
{
void
NnetCtcOutput
::
Write
(
std
::
ostream
&
os
,
bool
binary
)
const
{
WriteToken
(
os
,
binary
,
"<NnetCtcOutput>"
);
WriteToken
(
os
,
binary
,
name
);
WriteToken
(
os
,
binary
,
"<NumOutputs>"
);
int32
size
=
supervision
.
size
();
KALDI_ASSERT
(
size
>
0
&&
"Attempting to write empty NnetCtcOutput."
);
WriteBasicType
(
os
,
binary
,
size
);
if
(
!
binary
)
os
<<
"
\n
"
;
for
(
int32
i
=
0
;
i
<
size
;
i
++
)
{
supervision
[
i
].
Write
(
os
,
binary
);
if
(
!
binary
)
os
<<
"
\n
"
;
}
WriteToken
(
os
,
binary
,
"</NnetCtcOutput>"
);
}
void
NnetCtcOutput
::
Read
(
std
::
istream
&
is
,
bool
binary
)
{
ExpectToken
(
is
,
binary
,
"<NnetCtcOutput>"
);
ReadToken
(
is
,
binary
,
&
name
);
ExpectToken
(
is
,
binary
,
"<NumOutputs>"
);
int32
size
;
ReadBasicType
(
is
,
binary
,
&
size
);
KALDI_ASSERT
(
size
>
0
&&
size
<
1000000
);
supervision
.
resize
(
size
);
for
(
int32
i
=
0
;
i
<
size
;
i
++
)
supervision
[
i
].
Read
(
is
,
binary
);
ExpectToken
(
is
,
binary
,
"</NnetCtcOutput>"
);
}
void
NnetCtcOutput
::
GetIndexes
(
std
::
vector
<
Index
>
*
indexes
)
const
{
KALDI_ASSERT
(
!
supervision
.
empty
());
size_t
total_size
=
0
;
std
::
vector
<
ctc
::
CtcSupervision
>::
const_iterator
}
void
NnetCtcExample
::
Write
(
std
::
ostream
&
os
,
bool
binary
)
const
{
// Note: weight, label, input_frames and spk_info are members. This is a
// struct.
WriteToken
(
os
,
binary
,
"<Nnet3CtcEg>"
);
WriteToken
(
os
,
binary
,
"<NumInputs>"
);
int32
size
=
inputs
.
size
();
WriteBasicType
(
os
,
binary
,
size
);
KALDI_ASSERT
(
size
>
0
&&
"Attempting to write NnetCtcExample with no inputs"
);
if
(
!
binary
)
os
<<
'\n'
;
for
(
int32
i
=
0
;
i
<
size
;
i
++
)
{
inputs
[
i
].
Write
(
os
,
binary
);
if
(
!
binary
)
os
<<
'\n'
;
}
size
=
outputs
.
size
();
WriteBasicType
(
os
,
binary
,
size
);
KALDI_ASSERT
(
size
>
0
&&
"Attempting to write NnetCtcExample with no outputs"
);
if
(
!
binary
)
os
<<
'\n'
;
for
(
int32
i
=
0
;
i
<
size
;
i
++
)
{
outputs
[
i
].
Write
(
os
,
binary
);
if
(
!
binary
)
os
<<
'\n'
;
}
WriteToken
(
os
,
binary
,
"</Nnet3CtcEg>"
);
}
void
NnetCtcExample
::
Read
(
std
::
istream
&
is
,
bool
binary
)
{
ExpectToken
(
is
,
binary
,
"<Nnet3CtcEg>"
);
ExpectToken
(
is
,
binary
,
"<NumInputs>"
);
int32
size
;
ReadBasicType
(
is
,
binary
,
&
size
);
if
(
size
<
1
||
size
>
1000000
)
KALDI_ERR
<<
"Invalid size "
<<
size
;
inputs
.
resize
(
size
);
for
(
int32
i
=
0
;
i
<
size
;
i
++
)
inputs
[
i
].
Read
(
is
,
binary
);
ExpectToken
(
is
,
binary
,
"<NumOutputs>"
);
ReadBasicType
(
is
,
binary
,
&
size
);
if
(
size
<
1
||
size
>
1000000
)
KALDI_ERR
<<
"Invalid size "
<<
size
;
outputs
.
resize
(
size
);
for
(
int32
i
=
0
;
i
<
size
;
i
++
)
outputs
[
i
].
Read
(
is
,
binary
);
ExpectToken
(
is
,
binary
,
"</Nnet3CtcEg>"
);
}
void
NnetCtcExample
::
Swap
(
NnetCtcExample
*
other
)
{
inputs
.
swap
(
other
->
inputs
);
outputs
.
swap
(
other
->
outputs
);
}
void
NnetCtcExample
::
Compress
()
{
std
::
vector
<
NnetIo
>::
iterator
iter
=
inputs
.
begin
(),
end
=
inputs
.
end
();
// calling features.Compress() will do nothing if they are sparse or already
// compressed.
for
(;
iter
!=
end
;
++
iter
)
iter
->
features
.
Compress
();
}
}
// namespace nnet3
}
// namespace kaldi
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment