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

Errors in usage page. #43

Open
sodoherty-ai opened this issue Aug 22, 2022 · 5 comments
Open

Errors in usage page. #43

sodoherty-ai opened this issue Aug 22, 2022 · 5 comments

Comments

@sodoherty-ai
Copy link

sodoherty-ai commented Aug 22, 2022

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
Copy link
Author

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]

@michalkordyzon
Copy link
Contributor

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

@NaweedAghmad
Copy link
Collaborator

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

@qdin4048
Copy link

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

@buddha314
Copy link

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

image

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

5 participants