Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RL-Parsing
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
RL-Parsing
Commits
36342444
Commit
36342444
authored
4 years ago
by
maxime.petit
Browse files
Options
Downloads
Patches
Plain Diff
Added new reward func
parent
67b8b07c
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Rl.py
+30
-0
30 additions, 0 deletions
Rl.py
with
30 additions
and
0 deletions
Rl.py
+
30
−
0
View file @
36342444
...
@@ -2,6 +2,7 @@ import sys
...
@@ -2,6 +2,7 @@ import sys
import
random
import
random
import
torch
import
torch
import
torch.nn.functional
as
F
import
torch.nn.functional
as
F
import
numpy
as
np
from
Util
import
getDevice
from
Util
import
getDevice
################################################################################
################################################################################
...
@@ -152,3 +153,32 @@ def rewardE(appliable, config, action, missingLinks):
...
@@ -152,3 +153,32 @@ def rewardE(appliable, config, action, missingLinks):
return
reward
return
reward
################################################################################
################################################################################
################################################################################
def
rewardF
(
appliable
,
config
,
action
,
missingLinks
):
if
appliable
:
if
"
BACK
"
not
in
action
.
name
:
reward
=
-
1.0
*
action
.
getOracleScore
(
config
,
missingLinks
)
else
:
back
=
action
.
size
error_in_pop
=
[
i
for
i
in
range
(
1
,
back
)
if
config
.
historyPop
[
-
i
][
3
]
<
0
]
last_error
=
error_in_pop
[
-
1
]
if
len
(
error_in_pop
)
>
0
else
0
reward
=
last_error
-
back
else
:
reward
=
-
3.0
return
10
*
reward
################################################################################
################################################################################
def
rewardG
(
appliable
,
config
,
action
,
missingLinks
):
if
appliable
:
if
"
BACK
"
not
in
action
.
name
:
reward
=
-
action
.
getOracleScore
(
config
,
missingLinks
)
else
:
back
=
action
.
size
canceledRewards
=
[
h
[
3
]
for
h
in
config
.
historyPop
[
-
back
:]]
reward
=
np
.
log
(
1
-
sum
(
canceledRewards
))
if
-
sum
(
canceledRewards
)
>
0
else
-
1
else
:
reward
=
-
3.0
return
reward
################################################################################
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