A_a2 = ltn.Clause([ltn.Literal(True, A, a2)], label="A_a2")
A_a3 = ltn.Clause([ltn.Literal(True, A, a3)], label="A_a3")

B_b1 = ltn.Clause([ltn.Literal(True, B, b1)], label="B_b1")
B_b2 = ltn.Clause([ltn.Literal(True, B, b2)], label="B_b2")
B_b3 = ltn.Clause([ltn.Literal(True, B, b3)], label="B_b3")

A_or_B_c = ltn.Clause(
    [ltn.Literal(True, A, c), ltn.Literal(True, B, c)], label="A_c1_v_B_c1")

A_imp_not_B = ltn.Clause(
    [ltn.Literal(False, A, person),
     ltn.Literal(False, B, person)],
    label="A_imp_not_B")

couple_and_a1d = ltn.Domain_union([couple, ltn.Domain_concat([a1, d])])

Rxy_imp_Ax = ltn.Clause([
    ltn.Literal(False, R, couple_and_a1d),
    ltn.Literal(True, A, ltn.Domain_slice(couple_and_a1d, 0, 3))
],
                        label="Rxy_imp_Ax")

Rxy_imp_By = ltn.Clause([
    ltn.Literal(False, R, couple_and_a1d),
    ltn.Literal(True, B, ltn.Domain_slice(couple_and_a1d, 3, 6))
],
                        label="Rxy_imp_By")

couples_in_R = ltn.Domain(number_of_features * 2, label="Couples_in_R")
예제 #2
0
파일: persons_spc.py 프로젝트: apogre/LTN
import logictensornetworks as ltn
import numpy as np

number_of_features = 100
#identity matrix 30 * 30
features_for_generic_peoples = np.identity(number_of_features).tolist()

person = ltn.Domain_union([
    ltn.Constant("p" + str(i), features_for_generic_peoples[i])
    for i in range(number_of_features)
])

everybody = []

spouse_set = []
parents_set = []
children_set = []
예제 #3
0
파일: SPC_example.py 프로젝트: apogre/LTN
ltn.default_layers = 4
ltn.default_smooth_factor = 1e-10
ltn.default_tnorm = "luk"
ltn.default_aggregator ="hmean"
ltn.default_optimizer = "rmsprop"
ltn.default_clauses_aggregator = "hmean"
ltn.default_fact_penality = 1e-6

# first_group = [barack, michelle, sasha, malia]
#
# second_group = [bill, hillary, chelsea]
#
# everybody = first_group + second_group

person = ltn.Domain_union(everybody)

p1p1 = ltn.Domain_concat([person, person])

# p1p2 = ltn.Domain_product(person, person)
#
# p1 = ltn.Domain_slice(p1p2, 0, number_of_features)
#
# p2 = ltn.Domain_slice(p1p2, number_of_features, number_of_features*2)
#
# p2p1 = ltn.Domain_concat([p2, p1])
#reversing p1p2, each of individual persons
#
# some_friend = ltn.Function("some_friend", person, person)
#
# some_friend_of_person = ltn.Term(some_friend, person)