LNN icon indicating copy to clipboard operation
LNN copied to clipboard

Errors in usage page.

Open sodoherty-ai opened this issue 2 years ago • 5 comments

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:

sodoherty-ai avatar Aug 22 '22 11:08 sodoherty-ai

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]

sodoherty-ai avatar Aug 22 '22 13:08 sodoherty-ai

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

michalkordyzon avatar Sep 04 '22 21:09 michalkordyzon

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

NaweedAghmad avatar Sep 05 '22 08:09 NaweedAghmad

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:)

qdin4048 avatar Oct 19 '22 04:10 qdin4048

Not as urgent, but a typo in the page https://ibm.github.io/LNN/usage.html

image

buddha314 avatar Oct 19 '22 14:10 buddha314