Skip to content

Machine learning examples #15

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

sakchal
Copy link
Contributor

@sakchal sakchal commented Apr 15, 2024

This PR introduces a directory of common examples taken from the old high-level python library to serve as examples in the new high-level python API.

This PR introduces a new examples file including:
mnist_common.py
logistic_regression.py

Makes changes to files:
init.py - added lookup to the functions that's imported from the arrayfire library on initialization
array.py - added lookup to the list of visible functions

@roaffix
Copy link
Owner

roaffix commented Apr 18, 2024

This PR needs to be rebased on the current master state and mypy typings should be added

@sakchal sakchal force-pushed the machine_learning_examples branch from 95d2870 to 0268f66 Compare April 22, 2024 15:13
@sakchal
Copy link
Contributor Author

sakchal commented Apr 25, 2024

There were mypy issues, but those were from files I haven't touched. Should I go in and fix those too?

@roaffix
Copy link
Owner

roaffix commented Apr 25, 2024

There were mypy issues, but those were from files I haven't touched. Should I go in and fix those too?

Could you please paste the screenshot or traceback of those errors?

@sakchal
Copy link
Contributor Author

sakchal commented Apr 26, 2024

These were the mypy errors that failed the check:

arrayfire/array_object.py:90: error: Item "str" of "Any | str" has no attribute "typecode" [union-attr] arrayfire/array_object.py:91: error: Item "str" of "Any | str" has no attribute "typecode" [union-attr] arrayfire/array_object.py:108: error: Item "str" of "Any | str" has no attribute "typecode" [union-attr] arrayfire/array_object.py:119: error: Item "str" of "Any | str" has no attribute "typecode" [union-attr] arrayfire/array_object.py:741: error: Variable "arrayfire.array_object.IndexKey" is not valid as a type [valid-type] arrayfire/array_object.py:741: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases arrayfire/array_object.py:765: error: IndexKey? has no attribute "arr" [attr-defined] arrayfire/array_object.py:783: error: Variable "arrayfire.array_object.IndexKey" is not valid as a type [valid-type] arrayfire/array_object.py:783: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases arrayfire/array_object.py:790: error: IndexKey? has no attribute "arr" [attr-defined] arrayfire/array_object.py:790: note: Error code "attr-defined" not covered by "type: ignore" comment arrayfire/array_object.py:901: error: Returning Any from function declared to return "int" [no-any-return] arrayfire/array_object.py:911: error: Returning Any from function declared to return "int" [no-any-return] arrayfire/array_object.py:924: error: Returning Any from function declared to return "tuple[int, ...]" [no-any-return] arrayfire/array_object.py:936: error: Returning Any from function declared to return "int" [no-any-return] arrayfire/array_object.py:948: error: Returning Any from function declared to return "tuple[int, ...]" [no-any-return] arrayfire/array_object.py:959: error: Returning Any from function declared to return "int | float | bool | complex | None" [no-any-return] arrayfire/array_object.py:965: error: Returning Any from function declared to return "bool" [no-any-return] arrayfire/array_object.py:993: error: Returning Any from function declared to return "Array[Any]" [no-any-return] arrayfire/array_object.py:1033: error: Returning Any from function declared to return "bool" [no-any-return] arrayfire/array_object.py:1037: error: Returning Any from function declared to return "bool" [no-any-return] arrayfire/array_object.py:1041: error: Returning Any from function declared to return "bool" [no-any-return] arrayfire/array_object.py:1045: error: Returning Any from function declared to return "bool" [no-any-return] arrayfire/array_object.py:1049: error: Returning Any from function declared to return "bool" [no-any-return] arrayfire/array_object.py:1053: error: Returning Any from function declared to return "bool" [no-any-return] arrayfire/array_object.py:1057: error: Returning Any from function declared to return "bool" [no-any-return] arrayfire/array_object.py:1061: error: Returning Any from function declared to return "bool" [no-any-return] arrayfire/array_object.py:1065: error: Returning Any from function declared to return "bool" [no-any-return] arrayfire/array_object.py:1069: error: Returning Any from function declared to return "bool" [no-any-return] arrayfire/array_object.py:1073: error: Returning Any from function declared to return "bool" [no-any-return] arrayfire/array_object.py:1077: error: Returning Any from function declared to return "bool" [no-any-return] arrayfire/array_object.py:1081: error: Returning Any from function declared to return "bool" [no-any-return] arrayfire/array_object.py:1085: error: Returning Any from function declared to return "bool" [no-any-return] arrayfire/array_object.py:1089: error: Returning Any from function declared to return "bool" [no-any-return] arrayfire/array_object.py:1093: error: Returning Any from function declared to return "int" [no-any-return] arrayfire/array_object.py:1097: error: Returning Any from function declared to return "bool" [no-any-return] arrayfire/array_object.py:1100: error: Returning Any from function declared to return "None" [no-any-return] arrayfire/array_object.py:1103: error: Returning Any from function declared to return "None" [no-any-return] arrayfire/array_object.py:1[14](https://github.com/roaffix/arrayfire-py/actions/runs/8836675552/job/24263804453?pr=15#step:6:15)3: error: Variable "arrayfire.array_object.IndexKey" is not valid as a type [valid-type] arrayfire/array_object.py:1143: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases arrayfire/array_object.py:1145: error: Value of type IndexKey? is not indexable [index] arrayfire/array_object.py:1188: error: Returning Any from function declared to return "str" [no-any-return] arrayfire/library/vector_algorithms.py:237: error: Returning Any from function declared to return "int | float | complex | Array" [no-any-return] arrayfire/library/vector_algorithms.py:239: error: Returning Any from function declared to return "int | float | complex | Array" [no-any-return] arrayfire/library/vector_algorithms.py:291: error: Returning Any from function declared to return "int | float | complex | Array" [no-any-return] arrayfire/library/vector_algorithms.py:293: error: Returning Any from function declared to return "int | float | complex | Array" [no-any-return] arrayfire/library/vector_algorithms.py:379: error: Returning Any from function declared to return "int | float | complex | Array | tuple[Array, Array]" [no-any-return] arrayfire/library/vector_algorithms.py:449: error: Returning Any from function declared to return "tuple[int | float | complex, int] | tuple[Array, Array]" [no-any-return] arrayfire/library/vector_algorithms.py:531: error: Returning Any from function declared to return "int | float | complex | Array | tuple[Array, Array]" [no-any-return] arrayfire/library/vector_algorithms.py:589: error: Returning Any from function declared to return "tuple[int | float | complex, int] | tuple[Array, Array]" [no-any-return] arrayfire/library/vector_algorithms.py:647: error: Returning Any from function declared to return "int | float | complex | Array" [no-any-return] arrayfire/library/statistics.py:[16](https://github.com/roaffix/arrayfire-py/actions/runs/8836675552/job/24263804453?pr=15#step:6:17): error: Returning Any from function declared to return "int | float | complex" [no-any-return] arrayfire/library/statistics.py:43: error: Returning Any from function declared to return "int | float | complex | Array" [no-any-return] arrayfire/library/statistics.py:48: error: Returning Any from function declared to return "int | float | complex | Array" [no-any-return] arrayfire/library/statistics.py:63: error: Returning Any from function declared to return "int | float | complex | Array" [no-any-return] arrayfire/library/statistics.py:80: error: Returning Any from function declared to return "int | float | complex | Array" [no-any-return] arrayfire/library/statistics.py:120: error: Returning Any from function declared to return "int | float | complex | Array" [no-any-return] arrayfire/library/statistics.py:125: error: Returning Any from function declared to return "int | float | complex | Array" [no-any-return] arrayfire/library/random.py:101: error: Returning Any from function declared to return "int" [no-any-return] arrayfire/library/linear_algebra.py:81: error: Returning Any from function declared to return "int | float | complex | Array" [no-any-return] arrayfire/library/linear_algebra.py:208: error: Returning Any from function declared to return "int | tuple[Array, int]" [no-any-return] arrayfire/library/linear_algebra.py:256: error: Returning Any from function declared to return "int | float | complex" [no-any-return] arrayfire/library/linear_algebra.py:265: error: Returning Any from function declared to return "float" [no-any-return] arrayfire/library/linear_algebra.py:274: error: Returning Any from function declared to return "int" [no-any-return] arrayfire/library/input_and_output.py:37: error: Returning Any from function declared to return "int" [no-any-return] arrayfire/library/input_and_output.py:56: error: Returning Any from function declared to return "None" [no-any-return] arrayfire/library/features.py:41: error: Returning Any from function declared to return "int" [no-any-return] arrayfire/array_api/_data_type_functions.py:3[17](https://github.com/roaffix/arrayfire-py/actions/runs/8836675552/job/24263804453?pr=15#step:6:18): error: Returning Any from function declared to return "bool" [no-any-return] examples/benchmarks/monte_carlo_pi.py:40: error: Overloaded function signature 3 will never be matched: signature 2's parameter type(s) are the same or broader [misc] Found 65 errors in 9 files (checked 65 source files)

@roaffix
Copy link
Owner

roaffix commented Apr 26, 2024

These were the mypy errors that failed the check:

arrayfire/array_object.py:90: error: Item "str" of "Any | str" has no attribute "typecode" [union-attr] arrayfire/array_object.py:91: error: Item "str" of "Any | str" has no attribute "typecode" [union-attr] arrayfire/array_object.py:108: error: Item "str" of "Any | str" has no attribute "typecode" [union-attr] arrayfire/array_object.py:119: error: Item "str" of "Any | str" has no attribute "typecode" [union-attr] arrayfire/array_object.py:741: error: Variable "arrayfire.array_object.IndexKey" is not valid as a type [valid-type] arrayfire/array_object.py:741: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases arrayfire/array_object.py:765: error: IndexKey? has no attribute "arr" [attr-defined] arrayfire/array_object.py:783: error: Variable "arrayfire.array_object.IndexKey" is not valid as a type [valid-type] arrayfire/array_object.py:783: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases arrayfire/array_object.py:790: error: IndexKey? has no attribute "arr" [attr-defined] arrayfire/array_object.py:790: note: Error code "attr-defined" not covered by "type: ignore" comment arrayfire/array_object.py:901: error: Returning Any from function declared to return "int" [no-any-return] arrayfire/array_object.py:911: error: Returning Any from function declared to return "int" [no-any-return] arrayfire/array_object.py:924: error: Returning Any from function declared to return "tuple[int, ...]" [no-any-return] arrayfire/array_object.py:936: error: Returning Any from function declared to return "int" [no-any-return] arrayfire/array_object.py:948: error: Returning Any from function declared to return "tuple[int, ...]" [no-any-return] arrayfire/array_object.py:959: error: Returning Any from function declared to return "int | float | bool | complex | None" [no-any-return] arrayfire/array_object.py:965: error: Returning Any from function declared to return "bool" [no-any-return] arrayfire/array_object.py:993: error: Returning Any from function declared to return "Array[Any]" [no-any-return] arrayfire/array_object.py:1033: error: Returning Any from function declared to return "bool" [no-any-return] arrayfire/array_object.py:1037: error: Returning Any from function declared to return "bool" [no-any-return] arrayfire/array_object.py:1041: error: Returning Any from function declared to return "bool" [no-any-return] arrayfire/array_object.py:1045: error: Returning Any from function declared to return "bool" [no-any-return] arrayfire/array_object.py:1049: error: Returning Any from function declared to return "bool" [no-any-return] arrayfire/array_object.py:1053: error: Returning Any from function declared to return "bool" [no-any-return] arrayfire/array_object.py:1057: error: Returning Any from function declared to return "bool" [no-any-return] arrayfire/array_object.py:1061: error: Returning Any from function declared to return "bool" [no-any-return] arrayfire/array_object.py:1065: error: Returning Any from function declared to return "bool" [no-any-return] arrayfire/array_object.py:1069: error: Returning Any from function declared to return "bool" [no-any-return] arrayfire/array_object.py:1073: error: Returning Any from function declared to return "bool" [no-any-return] arrayfire/array_object.py:1077: error: Returning Any from function declared to return "bool" [no-any-return] arrayfire/array_object.py:1081: error: Returning Any from function declared to return "bool" [no-any-return] arrayfire/array_object.py:1085: error: Returning Any from function declared to return "bool" [no-any-return] arrayfire/array_object.py:1089: error: Returning Any from function declared to return "bool" [no-any-return] arrayfire/array_object.py:1093: error: Returning Any from function declared to return "int" [no-any-return] arrayfire/array_object.py:1097: error: Returning Any from function declared to return "bool" [no-any-return] arrayfire/array_object.py:1100: error: Returning Any from function declared to return "None" [no-any-return] arrayfire/array_object.py:1103: error: Returning Any from function declared to return "None" [no-any-return] arrayfire/array_object.py:1[14](https://github.com/roaffix/arrayfire-py/actions/runs/8836675552/job/24263804453?pr=15#step:6:15)3: error: Variable "arrayfire.array_object.IndexKey" is not valid as a type [valid-type] arrayfire/array_object.py:1143: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases arrayfire/array_object.py:1145: error: Value of type IndexKey? is not indexable [index] arrayfire/array_object.py:1188: error: Returning Any from function declared to return "str" [no-any-return] arrayfire/library/vector_algorithms.py:237: error: Returning Any from function declared to return "int | float | complex | Array" [no-any-return] arrayfire/library/vector_algorithms.py:239: error: Returning Any from function declared to return "int | float | complex | Array" [no-any-return] arrayfire/library/vector_algorithms.py:291: error: Returning Any from function declared to return "int | float | complex | Array" [no-any-return] arrayfire/library/vector_algorithms.py:293: error: Returning Any from function declared to return "int | float | complex | Array" [no-any-return] arrayfire/library/vector_algorithms.py:379: error: Returning Any from function declared to return "int | float | complex | Array | tuple[Array, Array]" [no-any-return] arrayfire/library/vector_algorithms.py:449: error: Returning Any from function declared to return "tuple[int | float | complex, int] | tuple[Array, Array]" [no-any-return] arrayfire/library/vector_algorithms.py:531: error: Returning Any from function declared to return "int | float | complex | Array | tuple[Array, Array]" [no-any-return] arrayfire/library/vector_algorithms.py:589: error: Returning Any from function declared to return "tuple[int | float | complex, int] | tuple[Array, Array]" [no-any-return] arrayfire/library/vector_algorithms.py:647: error: Returning Any from function declared to return "int | float | complex | Array" [no-any-return] arrayfire/library/statistics.py:[16](https://github.com/roaffix/arrayfire-py/actions/runs/8836675552/job/24263804453?pr=15#step:6:17): error: Returning Any from function declared to return "int | float | complex" [no-any-return] arrayfire/library/statistics.py:43: error: Returning Any from function declared to return "int | float | complex | Array" [no-any-return] arrayfire/library/statistics.py:48: error: Returning Any from function declared to return "int | float | complex | Array" [no-any-return] arrayfire/library/statistics.py:63: error: Returning Any from function declared to return "int | float | complex | Array" [no-any-return] arrayfire/library/statistics.py:80: error: Returning Any from function declared to return "int | float | complex | Array" [no-any-return] arrayfire/library/statistics.py:120: error: Returning Any from function declared to return "int | float | complex | Array" [no-any-return] arrayfire/library/statistics.py:125: error: Returning Any from function declared to return "int | float | complex | Array" [no-any-return] arrayfire/library/random.py:101: error: Returning Any from function declared to return "int" [no-any-return] arrayfire/library/linear_algebra.py:81: error: Returning Any from function declared to return "int | float | complex | Array" [no-any-return] arrayfire/library/linear_algebra.py:208: error: Returning Any from function declared to return "int | tuple[Array, int]" [no-any-return] arrayfire/library/linear_algebra.py:256: error: Returning Any from function declared to return "int | float | complex" [no-any-return] arrayfire/library/linear_algebra.py:265: error: Returning Any from function declared to return "float" [no-any-return] arrayfire/library/linear_algebra.py:274: error: Returning Any from function declared to return "int" [no-any-return] arrayfire/library/input_and_output.py:37: error: Returning Any from function declared to return "int" [no-any-return] arrayfire/library/input_and_output.py:56: error: Returning Any from function declared to return "None" [no-any-return] arrayfire/library/features.py:41: error: Returning Any from function declared to return "int" [no-any-return] arrayfire/array_api/_data_type_functions.py:3[17](https://github.com/roaffix/arrayfire-py/actions/runs/8836675552/job/24263804453?pr=15#step:6:18): error: Returning Any from function declared to return "bool" [no-any-return] examples/benchmarks/monte_carlo_pi.py:40: error: Overloaded function signature 3 will never be matched: signature 2's parameter type(s) are the same or broader [misc] Found 65 errors in 9 files (checked 65 source files)

Is arrayfire-python-wrapper installed in your local environment?

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

Successfully merging this pull request may close these issues.

2 participants