LNN
LNN copied to clipboard
Errors in usage page.
Relates to this: https://ibm.github.io/LNN/usage.html
Step 2b: Sample code has a missing comma
formulae = [
Smoking_causes_Cancer
Smokers_befriend_Smokers
]
Step 3: Sample code at start generates error: TypeError: formula expected of type Formula, received str
Trace:
File LNN/lnn/model.py:346, in Model.add_data(self, data)
344 for formula, fact in data.items():
345 if not isinstance(formula, Formula):
--> 346 raise TypeError(
347 "formula expected of type Formula, received "
348 f"{formula.__class__.__name__}"
349 )
350 _exceptions.AssertFormulaInModel(self, formula)
351 if formula.propositional:
Removing the .name
allows the code to complete.
Trying to do the next step in the code generates the error: AttributeError: 'tuple' object has no attribute 'remove'
Trace:
LNN/lnn/symbolic/_gm.py:104, in downward_bounds(self, operands, groundings)
101 return None
103 for g in contradicting_groundings:
--> 104 groundings.remove(g)
106 output_bounds = output_bounds[~contradictions]
107 input_bounds = input_bounds[~contradictions]
I got same problems, thanks for suggestions @sodoherty-ai .
After removing .name
in model.add_data
part I got error in model.add_labels
: AttributeError: 'str' object has no attribute 'formula_number'
Removing quotation marks from Smokes
helped (at least did not throw an error), but not sure what I am doing.
Finally I am stuck on this sentence: model.train(losses=Loss.SUPERVISED)
with error: TypeError: list indices must be integers or slices, not Loss
Removing quotation marks from
Smokes
helped (at least did not throw an error), but not sure what I am doing.
Looks like there is some missing exception handling here. The inputs should be Formula objects and not the strings that represent these objects. Smokes
is correct but 'Smokes'
is not (this was an older API that has since been deprecated)
Finally I am stuck on this sentence:
model.train(losses=Loss.SUPERVISED)
with error:TypeError: list indices must be integers or slices, not Loss
Related to #42
Hi michalkordyzon,
Just find out, try to input "Loss.SUPERVISED" in the form of a list like this: model.train(losses=[Loss.SUPERVISED]). It works for me:)
Not as urgent, but a typo in the page https://ibm.github.io/LNN/usage.html