-
Notifications
You must be signed in to change notification settings - Fork 446
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
model serialisation #23
Comments
Do we want human-readable serialization like |
We can start with byte-code, having the ability to dump and load a model is more important than having the dump human-readable right now. |
Simple usage example and API proposition: from lnn import Predicate, Variable, And, Model, Fact
model = Model()
x = Variable("x")
p1 = Predicate(name="p1")
p2 = Predicate(name="p2")
formula = And(p1(x), p2(x))
model.add_formulae(p1, p2, formula)
model.add_facts(
{"p1": {"a": Fact.TRUE, "b": Fact.FALSE}, "p2": {"a": Fact.FALSE, "b": Fact.FALSE}}
)
model.infer()
model.save("my_model")
loaded_model = Model.from_file("my_model")
assert model == loaded_model @NaweedAghmad Possible problem is that we do not have The |
Would Pickle Work Like: def save(self, filename):
with open(filename, 'wb') as outp: # Overwrites any existing file.
pickle.dump(self, outp, pickle.HIGHEST_PROTOCOL)
def from_file(self,filename):
with open(filename, 'rb') as inp:
return pickle.load(inp)
if so i would be happy to contribute @NaweedAghmad |
Serialize all model rules and facts reflective of
model.print
The text was updated successfully, but these errors were encountered: