-
Notifications
You must be signed in to change notification settings - Fork 392
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
AttributeError: 'NoneType' object has no attribute 'span' #1080
Comments
Thank you for reporting this error. Could you please tell us which Python version you're using? |
I am using Python version 3.13.1 |
Okay, so this is a problem with Python 3.13. As skorch does not officially support 3.13 yet*, we didn't catch that problem. The issue is a bit subtle. When we print the start of the Below is 3.12:
vs 3.13:
This is because
(link) This messes with our parsing code of the docstring. The correct solution is thus to fix the parsing code so that it works both with and without leading whitespace on each line. Regarding your problem @raphaelrubrice, I would recommend to downgrade to Python 3.12 if possible. Also, let me know if you're interested in creating a PR to fix the issue. *PyTorch now works with Python 3.13, so we could indeed add support in skorch. |
Thank you for identifiying the source of the issue. Yes I think I'd be interested, I'll try to find a real fix then. |
Okay so I think I found a solution. There were two issues : 1) Regexp was no longer valid when leading whitespace were removed as @BenjaminBossan previously stated.With python 3.12 (criterion block is correctly processed by regexp): criterion : torch criterion (class)
The uninitialized criterion (loss) used to optimize the
module. With 3.13 because of whitespace removal, the block was not recognized because of the absence of whitespace required by the regexp when specifying (\s.+) at the end. 2) The first line of the function that modifies the documentation had a small mistake in it :def get_neural_net_reg_doc(doc):
doc = neural_net_reg_doc_start + " " + doc.split("\n ", 4)[-1] split argument should be 3 instead of 4 because otherwise the criterion block was getting removed so even with the proper regexp there was no criterion block to match anymore. So this was fixed by setting : def get_neural_net_reg_doc(doc):
doc = neural_net_reg_doc_start + " " + doc.split("\n ", 3)[-1] I tested imports from 3.13 and 3.12 and it now works fine. I made a PRPS: I fixed it for NeuralNetClassifier and NeuralNetBinaryCasiffier also as the issue was the exact same. Thanks again, |
Update on this issue : Missing paragraph stems from one However this change leads to The other issue was incorrect indentation. By using |
Hello,
I am a new user of skorch. When trying to import NeuralNetRegressor I got the error : AttributeError: 'NoneType' object has no attribute 'span'.
This error stems from the documentation retrieval. Either a change in documentation format or a change in the documentation retrieving fonction is causing this error ? Here is the error I got :
As it was not a functionality issue, I bypassed the error by defining in the file defining NeuralNetClassifier, NeuralNetRegressor and NeuralNetBinaryClassifier the function get_neural_net_reg_doc by adding a check, changing the function from :
This :
To this :
I hope this helps. This is my first time posting an issue on Github, if this was not helpful do not hesitate to tell me so.
Have a good day !
Raphaël.
The text was updated successfully, but these errors were encountered: