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

TypeError: unsupported operand type(s) for +: 'NoneType' and 'Fn' #5

Open
fabianbauermarquart opened this issue May 23, 2021 · 0 comments

Comments

@fabianbauermarquart
Copy link

fabianbauermarquart commented May 23, 2021

When executing the following adapted example code given in querying/README.md

import torch

import dl2lib as dl2
import dl2lib.query as q
from configargparse import ArgumentParser

from querying.models.mnist.main import Net1

my_pytorch_model = Net1()
my_pytorch_model.load_state_dict(torch.load('models/mnist/mnist_1.pt'))


def high_level_query():
    qtext = """FIND i[10]
    S.T. i[0] + i[3] < NN(i[4])"""  # actualy query
    context = dict()  # a python dict that defines models and named constants
    context['NN'] = my_pytorch_model
    parser = ArgumentParser(description='DL2 Querying')
    parser = dl2.add_default_parser_args(parser, query=True)
    args = parser.parse_args()  # additionaly arguments such as timeout etc.
    success, result, time = q.Query(qtext, context=context, args=args).run()

if __name__ == '__main__':
    high_level_query()

the following error occurs:

Traceback (most recent call last):
  File "~/dl2-master/querying/example_query.py", line 36, in <module>
    variant1()
  File "~/dl2-master/querying/example_query.py", line 21, in variant1
    success, result, time = q.Query(qtext, context=context, args=args).run()
  File "~/dl2-master/dl2lib/query/query.py", line 11, in __init__
    self.constraint, self.return_values = Parser(query, self.context, self.args).parse()
  File "~/dl2-master/dl2lib/query/parser.py", line 42, in parse
    return self.generate_find()
  File "~/dl2-master/dl2lib/query/parser.py", line 50, in generate_find
    constraints = self.traverse_constraints(self.parse_tree.find.constraints.constraints)
  File "~/dl2-master/dl2lib/query/parser.py", line 153, in traverse_constraints
    c1 = self.traverse_constraint(constraint.c1)
  File "~/dl2-master/dl2lib/query/parser.py", line 137, in traverse_constraint
    lhs = self.traverse_expression(constraint.lhs)
  File "~/dl2-master/dl2lib/query/parser.py", line 127, in traverse_expression
    return eval(f"lhs {exp.op} rhs")
  File "<string>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'NoneType' and 'Fn'

The model mnist_1.pt was trained using the given training procedure train_models.sh from the querying directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant