Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
old_macaon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Franck Dary
old_macaon
Commits
f01908fb
Commit
f01908fb
authored
Feb 14, 2019
by
Franck Dary
Browse files
Options
Downloads
Patches
Plain Diff
Fixed bugs
parent
37acfeb0
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
decoder/src/Decoder.cpp
+50
-20
50 additions, 20 deletions
decoder/src/Decoder.cpp
maca_common/src/ProgramOutput.cpp
+0
-4
0 additions, 4 deletions
maca_common/src/ProgramOutput.cpp
with
50 additions
and
24 deletions
decoder/src/Decoder.cpp
+
50
−
20
View file @
f01908fb
...
@@ -139,12 +139,13 @@ void computeSpeed(std::chrono::time_point<std::chrono::system_clock> & pastTime,
...
@@ -139,12 +139,13 @@ void computeSpeed(std::chrono::time_point<std::chrono::system_clock> & pastTime,
void
computeAndPrintSequenceEntropy
(
Config
&
config
,
bool
&
justFlipped
,
Errors
&
errors
,
float
&
entropyAccumulator
,
int
&
nbActionsInSequence
)
void
computeAndPrintSequenceEntropy
(
Config
&
config
,
bool
&
justFlipped
,
Errors
&
errors
,
float
&
entropyAccumulator
,
int
&
nbActionsInSequence
)
{
{
if
(
ProgramParameters
::
printEntropy
||
ProgramParameters
::
errorAnalysis
)
if
(
config
.
getHead
()
>=
1
&&
config
.
getTape
(
ProgramParameters
::
sequenceDelimiterTape
)[
-
1
]
!=
ProgramParameters
::
sequenceDelimiter
)
{
if
(
config
.
getHead
()
>=
1
&&
config
.
getTape
(
ProgramParameters
::
sequenceDelimiterTape
)[
config
.
getHead
()
-
1
]
!=
ProgramParameters
::
sequenceDelimiter
)
justFlipped
=
false
;
justFlipped
=
false
;
if
((
config
.
getHead
()
>=
1
&&
config
.
getTape
(
ProgramParameters
::
sequenceDelimiterTape
)[
config
.
getHead
()
-
1
]
==
ProgramParameters
::
sequenceDelimiter
&&
!
justFlipped
))
if
((
config
.
getHead
()
>=
1
&&
config
.
getTape
(
ProgramParameters
::
sequenceDelimiterTape
)[
-
1
]
==
ProgramParameters
::
sequenceDelimiter
&&
!
justFlipped
))
justFlipped
=
true
;
if
(
justFlipped
&&
(
ProgramParameters
::
printEntropy
||
ProgramParameters
::
errorAnalysis
))
{
{
justFlipped
=
true
;
justFlipped
=
true
;
errors
.
newSequence
();
errors
.
newSequence
();
...
@@ -155,7 +156,6 @@ void computeAndPrintSequenceEntropy(Config & config, bool & justFlipped, Errors
...
@@ -155,7 +156,6 @@ void computeAndPrintSequenceEntropy(Config & config, bool & justFlipped, Errors
entropyAccumulator
=
0.0
;
entropyAccumulator
=
0.0
;
}
}
}
}
}
void
computeAndRecordEntropy
(
Config
&
config
,
Classifier
::
WeightedActions
&
weightedActions
,
float
&
entropyAccumulator
)
void
computeAndRecordEntropy
(
Config
&
config
,
Classifier
::
WeightedActions
&
weightedActions
,
float
&
entropyAccumulator
)
{
{
...
@@ -180,7 +180,8 @@ struct BeamNode
...
@@ -180,7 +180,8 @@ struct BeamNode
Config
config
;
Config
config
;
Action
*
action
;
Action
*
action
;
int
nbActions
;
int
nbActions
;
bool
justFlipped
;
int
lastFlippedIndex
;
double
getEntropy
()
double
getEntropy
()
{
{
...
@@ -189,15 +190,31 @@ struct BeamNode
...
@@ -189,15 +190,31 @@ struct BeamNode
return
totalEntropy
/
nbActions
;
return
totalEntropy
/
nbActions
;
}
}
void
setFlipped
()
{
if
(
config
.
getHead
()
>
lastFlippedIndex
&&
config
.
getTape
(
ProgramParameters
::
sequenceDelimiterTape
)[
-
1
]
==
ProgramParameters
::
sequenceDelimiter
)
{
justFlipped
=
true
;
lastFlippedIndex
=
config
.
getHead
();
}
else
{
justFlipped
=
false
;
}
}
BeamNode
(
TransitionMachine
&
tm
,
Config
&
config
)
:
tm
(
tm
),
config
(
config
)
BeamNode
(
TransitionMachine
&
tm
,
Config
&
config
)
:
tm
(
tm
),
config
(
config
)
{
{
justFlipped
=
false
;
totalEntropy
=
0.0
;
totalEntropy
=
0.0
;
nbActions
=
0
;
nbActions
=
0
;
lastFlippedIndex
=
0
;
config
.
setOutputFile
(
nullptr
);
config
.
setOutputFile
(
nullptr
);
config
.
totalEntropy
=
totalEntropy
;
config
.
totalEntropy
=
totalEntropy
;
}
}
BeamNode
(
BeamNode
&
other
,
Action
*
action
,
float
proba
)
:
tm
(
other
.
tm
),
config
(
other
.
config
)
BeamNode
(
BeamNode
&
other
,
Action
*
action
,
float
proba
)
:
tm
(
other
.
tm
),
config
(
other
.
config
)
{
{
justFlipped
=
false
;
lastFlippedIndex
=
other
.
lastFlippedIndex
;
totalEntropy
=
other
.
totalEntropy
+
proba
;
totalEntropy
=
other
.
totalEntropy
+
proba
;
this
->
action
=
action
;
this
->
action
=
action
;
nbActions
=
other
.
nbActions
+
1
;
nbActions
=
other
.
nbActions
+
1
;
...
@@ -288,6 +305,7 @@ void Decoder::decodeBeam()
...
@@ -288,6 +305,7 @@ void Decoder::decodeBeam()
std
::
vector
<
std
::
shared_ptr
<
BeamNode
>
>
beam
;
std
::
vector
<
std
::
shared_ptr
<
BeamNode
>
>
beam
;
std
::
vector
<
std
::
shared_ptr
<
BeamNode
>
>
otherBeam
;
std
::
vector
<
std
::
shared_ptr
<
BeamNode
>
>
otherBeam
;
std
::
vector
<
std
::
shared_ptr
<
BeamNode
>
>
justFlippedBeam
;
beam
.
emplace_back
(
new
BeamNode
(
tm
,
config
));
beam
.
emplace_back
(
new
BeamNode
(
tm
,
config
));
auto
sortBeam
=
[
&
beam
]()
auto
sortBeam
=
[
&
beam
]()
...
@@ -331,9 +349,6 @@ void Decoder::decodeBeam()
...
@@ -331,9 +349,6 @@ void Decoder::decodeBeam()
break
;
break
;
}
}
if
(
mustContinue
)
continue
;
beam
=
otherBeam
;
beam
=
otherBeam
;
sortBeam
();
sortBeam
();
beam
.
resize
(
std
::
min
((
int
)
beam
.
size
(),
ProgramParameters
::
beamSize
));
beam
.
resize
(
std
::
min
((
int
)
beam
.
size
(),
ProgramParameters
::
beamSize
));
...
@@ -363,11 +378,26 @@ void Decoder::decodeBeam()
...
@@ -363,11 +378,26 @@ void Decoder::decodeBeam()
computeAndRecordEntropy
(
config
,
node
->
weightedActions
,
entropyAccumulator
);
computeAndRecordEntropy
(
config
,
node
->
weightedActions
,
entropyAccumulator
);
computeAndPrintSequenceEntropy
(
config
,
justFlipped
,
errors
,
entropyAccumulator
,
nbActionsInSequence
);
computeAndPrintSequenceEntropy
(
config
,
justFlipped
,
errors
,
entropyAccumulator
,
nbActionsInSequence
);
}
}
node
->
setFlipped
();
}
}
if
(
justFlipped
)
for
(
unsigned
int
i
=
0
;
i
<
beam
.
size
();
i
++
)
{
{
beam
.
resize
(
std
::
min
(
1
,(
int
)
beam
.
size
()));
if
(
beam
[
i
]
->
justFlipped
)
{
justFlippedBeam
.
push_back
(
beam
[
i
]);
beam
[
i
]
=
beam
[
beam
.
size
()
-
1
];
beam
.
pop_back
();
i
--
;
}
}
if
((
int
)
justFlippedBeam
.
size
()
>=
ProgramParameters
::
beamSize
)
{
beam
=
justFlippedBeam
;
justFlippedBeam
.
clear
();
sortBeam
();
beam
.
resize
(
1
);
if
(
!
beam
.
empty
())
if
(
!
beam
.
empty
())
{
{
beam
[
0
]
->
totalEntropy
=
0.0
;
beam
[
0
]
->
totalEntropy
=
0.0
;
...
...
This diff is collapsed.
Click to expand it.
maca_common/src/ProgramOutput.cpp
+
0
−
4
View file @
f01908fb
...
@@ -17,10 +17,6 @@ void ProgramOutput::addLine(const std::string & line, float entropy, unsigned in
...
@@ -17,10 +17,6 @@ void ProgramOutput::addLine(const std::string & line, float entropy, unsigned in
outputIndexes
.
emplace_back
(
-
1
);
outputIndexes
.
emplace_back
(
-
1
);
if
(
outputIndexes
[
index
]
==
-
1
||
entropies
[
outputIndexes
[
index
]]
<
entropy
)
if
(
outputIndexes
[
index
]
==
-
1
||
entropies
[
outputIndexes
[
index
]]
<
entropy
)
{
if
(
outputIndexes
[
index
]
!=
-
1
)
fprintf
(
stderr
,
"REMPLACED ! <%u>
\n
"
,
index
);
outputIndexes
[
index
]
=
lines
.
size
()
-
1
;
outputIndexes
[
index
]
=
lines
.
size
()
-
1
;
}
}
}
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