Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Pedot Nicola
ltn-db-clean
Commits
9face37a
Commit
9face37a
authored
Sep 03, 2019
by
npedot
Browse files
adds feature_numeriche 20190903
parent
943208a2
Changes
1
Hide whitespace changes
Inline
Side-by-side
dbrepair/numeric_features_20190903.py
0 → 100644
View file @
9face37a
import
logging
;
logging
.
basicConfig
(
level
=
logging
.
INFO
)
import
numpy
as
np
import
tensorflow
as
tf
import
logictensornetworks_wrapper
as
ltnw
ltnw
.
constant
(
'a'
,
min_value
=
[
1.
,
2.
,
3.
,
0.
],
max_value
=
[
1.
,
2.
,
3.
,
100.
])
ltnw
.
constant
(
'b'
,
min_value
=
[
4.
,
5.
,
6.
,
0.
],
max_value
=
[
4.
,
5.
,
6.
,
100.
])
ltnw
.
constant
(
'c'
,
min_value
=
[
4.
,
5.
,
6.
,
0.
],
max_value
=
[
4.
,
5.
,
6.
,
100.
])
ltnw
.
constant
(
"ten"
,[
10.
])
ltnw
.
constant
(
"twenty"
,[
20.
])
print
(
ltnw
.
CONSTANTS
)
def
_close_eta
(
x
,
y
):
return
1
-
tf
.
abs
(
x
-
y
)
/
100.
ltnw
.
function
(
'eta'
,
4
,
fun_definition
=
lambda
x
:
x
[:,
3
])
ltnw
.
predicate
(
"close_eta"
,
2
,
_close_eta
)
ltnw
.
axiom
(
"close_eta(eta(a),ten)"
)
ltnw
.
axiom
(
"close_eta(eta(b),twenty)"
)
ltnw
.
axiom
(
"close_eta(eta(b),eta(c))"
)
ltnw
.
initialize_knowledgebase
(
optimizer
=
tf
.
train
.
RMSPropOptimizer
(
learning_rate
=
.
01
),
initial_sat_level_threshold
=
.
4
)
ltnw
.
train
(
max_epochs
=
20000
)
print
(
"eta(a)"
,
ltnw
.
ask
(
'eta(a)'
))
print
(
"eta(b)"
,
ltnw
.
ask
(
'eta(b)'
))
print
(
"eta(c)"
,
ltnw
.
ask
(
'eta(c)'
))
Write
Preview
Supports
Markdown
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