Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addding T5 model for spatial task #395

Open
wants to merge 1 commit into
base: Tasks
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions SpatialQARules/graph_spartun_rel.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
inside = question(name="inside")
cover = question(name="cover")
contain = question(name="contain")
# answer_class = question(name="answer_class", ConceptClass=EnumConcept,
# values=["yes", "no"])
output_for_loss = question(name="output_for_loss")

# Only one label of opposite concepts
exactL(left, right)
exactL(above, below)
Expand All @@ -52,9 +52,9 @@
ifL(andL(ans2('x'), existsL(inverse('s', path=('x', inverse)))),
ans1(path=('s', inv_question2)))

# Only inverse one way
inverse_list2 = [(near, near), (far, far), (touch, touch), (disconnected, disconnected), (overlap, overlap),
(coveredby, inside), (cover, contain)]
# 2 PMD : = entropy + beta * constraint_loss ( Train with no-constraint first then working on)
# symmetric
inverse_list2 = [(near, near), (far, far), (touch, touch), (disconnected, disconnected), (overlap, overlap)]
for ans1, ans2 in inverse_list2:
ifL(andL(ans1('x'), existsL(inverse('s', path=('x', inverse)))),
ans2(path=('s', inv_question2)))
Expand All @@ -64,6 +64,7 @@
tran_quest1, tran_quest2, tran_quest3 = transitive.has_a(arg11=question, arg22=question, arg33=question)

transitive_1 = [left, right, above, below, behind, front, inside, contain]

for rel in transitive_1:
ifL(andL(rel('x'),
existsL(transitive("t", path=('x', transitive))),
Expand Down Expand Up @@ -103,4 +104,14 @@
rel1(path=('to', tran_topo_quest2)),
rel2(path=('to', tran_topo_quest3))
),
rel2(path=('to', tran_topo_quest4)))
rel2(path=('to', tran_topo_quest4)))

tran_topo_3_1 = [left, right, above, below, behind, front, near, far, disconnected]
tran_topo_3_2 = [contain, cover]
for rel1 in tran_topo_3_1:
for rel2 in tran_topo_3_2:
ifL(andL(rel1('x'),
existsL(tran_topo('to', path=('x', tran_topo))),
rel1(path=('to', tran_topo_quest2)),
rel2(path=('to', tran_topo_quest3))),
rel1(path=('to', tran_topo_quest4)))
6 changes: 3 additions & 3 deletions SpatialQARules/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def main(args):
augmented=args.train_file.upper() == "SPARTUN",
batch_size=args.batch_size,
boolQL=boolQ,
rule=args.text_rules)
rule_text=args.text_rules)

test_file = "human_test.json" if args.test_file.upper() == "HUMAN" \
else "test.json"
Expand All @@ -180,7 +180,7 @@ def main(args):
size=args.test_size,
augmented=False,
batch_size=args.batch_size,
rule=args.text_rules)
rule_text=args.text_rules)

eval_file = "DataSet/human_dev.json" if args.test_file.upper() == "HUMAN" \
else "DataSet/boolQ/train.json" if args.train_file.upper() == "BOOLQ" else "DataSet/dev_Spartun.json"
Expand All @@ -190,7 +190,7 @@ def main(args):
augmented=False,
batch_size=args.batch_size,
boolQL=boolQ,
rule=args.text_rules)
rule_text=args.text_rules)
program_name = "PMD" if args.pmd else "Sampling" if args.sampling else "Base"
if args.loaded:
program.load("Models/" + args.loaded_file, map_location={'cuda:0': cur_device, 'cuda:1': cur_device})
Expand Down
Loading