Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Yoann HOUPERT
kaldi_2015
Commits
2e7ba80e
Commit
2e7ba80e
authored
Aug 05, 2015
by
Jan Trmal
Browse files
Fixing GCC 4.4 -std=gnu++0x compilation issues
parent
c9757e06
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
12 deletions
+13
-12
src/nnet2bin/nnet-shuffle-egs.cc
src/nnet2bin/nnet-shuffle-egs.cc
+13
-12
No files found.
src/nnet2bin/nnet-shuffle-egs.cc
View file @
2e7ba80e
...
...
@@ -32,13 +32,13 @@ int main(int argc, char *argv[]) {
const
char
*
usage
=
"Copy examples (typically single frames) for neural network training,
\n
"
"from the input to output, but randomly shuffle the order.
This program will keep
\n
"
"from the input to output, but randomly shuffle the order. This program will keep
\n
"
"all of the examples in memory at once, so don't give it too many.
\n
"
"
\n
"
"Usage: nnet-shuffle-egs [options] <egs-rspecifier> <egs-wspecifier>
\n
"
"
\n
"
"nnet-shuffle-egs --srand=1 ark:train.egs ark:shuffled.egs
\n
"
;
int32
srand_seed
=
0
;
int32
buffer_size
=
0
;
ParseOptions
po
(
usage
);
...
...
@@ -46,11 +46,11 @@ int main(int argc, char *argv[]) {
po
.
Register
(
"buffer-size"
,
&
buffer_size
,
"If >0, size of a buffer we use "
"to do limited-memory partial randomization. Otherwise, do "
"full randomization."
);
po
.
Read
(
argc
,
argv
);
srand
(
srand_seed
);
if
(
po
.
NumArgs
()
!=
2
)
{
po
.
PrintUsage
();
exit
(
1
);
...
...
@@ -64,22 +64,23 @@ int main(int argc, char *argv[]) {
std
::
vector
<
std
::
pair
<
std
::
string
,
NnetExample
*>
>
egs
;
SequentialNnetExampleReader
example_reader
(
examples_rspecifier
);
NnetExampleWriter
example_writer
(
examples_wspecifier
);
if
(
buffer_size
==
0
)
{
// Do full randomization
if
(
buffer_size
==
0
)
{
// Do full randomization
// Putting in an extra level of indirection here to avoid excessive
// computation and memory demands when we have to resize the vector.
for
(;
!
example_reader
.
Done
();
example_reader
.
Next
())
egs
.
push_back
(
std
::
make_pair
(
example_reader
.
Key
(),
egs
.
push_back
(
std
::
make_pair
(
example_reader
.
Key
(),
new
NnetExample
(
example_reader
.
Value
())));
std
::
random_shuffle
(
egs
.
begin
(),
egs
.
end
());
}
else
{
KALDI_ASSERT
(
buffer_size
>
0
);
egs
.
resize
(
buffer_size
,
std
::
pair
<
std
::
string
,
NnetExample
*>
(
""
,
NULL
));
egs
.
resize
(
buffer_size
,
std
::
pair
<
std
::
string
,
NnetExample
*>
(
""
,
static_cast
<
NnetExample
*>
(
NULL
)));
for
(;
!
example_reader
.
Done
();
example_reader
.
Next
())
{
int32
index
=
RandInt
(
0
,
buffer_size
-
1
);
if
(
egs
[
index
].
second
==
NULL
)
{
egs
[
index
]
=
std
::
make_pair
(
example_reader
.
Key
(),
egs
[
index
]
=
std
::
make_pair
(
example_reader
.
Key
(),
new
NnetExample
(
example_reader
.
Value
()));
}
else
{
example_writer
.
Write
(
egs
[
index
].
first
,
*
(
egs
[
index
].
second
));
...
...
@@ -87,7 +88,7 @@ int main(int argc, char *argv[]) {
*
(
egs
[
index
].
second
)
=
example_reader
.
Value
();
num_done
++
;
}
}
}
}
for
(
size_t
i
=
0
;
i
<
egs
.
size
();
i
++
)
{
if
(
egs
[
i
].
second
!=
NULL
)
{
...
...
@@ -100,7 +101,7 @@ int main(int argc, char *argv[]) {
KALDI_LOG
<<
"Shuffled order of "
<<
num_done
<<
" neural-network training examples "
<<
(
buffer_size
?
"using a buffer (partial randomization)"
:
""
);
return
(
num_done
==
0
?
1
:
0
);
}
catch
(
const
std
::
exception
&
e
)
{
std
::
cerr
<<
e
.
what
()
<<
'\n'
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment