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

Revised chunking implemented for Issue #67 for improved memory management #106

Merged
merged 2 commits into from
Dec 13, 2018

Conversation

behreth
Copy link
Contributor

@behreth behreth commented Dec 11, 2018

This closes issue #67 memory error on 32bit Python

Main change:

  • Created chunking logic to call the classifier with a maximum number of tests (detailed description as code comment).

In addition the following change was made:

  • Replaced the try/catch with an explicit check for the available function either decision_function or predict_proba.

Main change:
- Created chunking logic to call the classifier with a maximum number of tests (detailed description as code comment).

In addition the following change was made:
- Replaced the try/catch with an explicit check for the available function either decision_function or predict_proba.
@behreth
Copy link
Contributor Author

behreth commented Dec 11, 2018

For details of history see PR #105

y_chunk_pos = 0
for x_chunk in np.array_split(X, np.arange(chunk_size,X_axis0_size,chunk_size,dtype=np.int32), axis=0):
Y_result_chunks.append(classifier_pred_or_decide(x_chunk))
y_chunk_pos += x_chunk.shape[0]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this variable is not used, is it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct; and I inlined the
X_axis0_size
removing this as well.

# MLPClassifier(solver='lbfgs', random_state=0, hidden_layer_sizes=[1000,1000,1000])
# by reducing the value it is possible to trade in time for memory.
# It is possible to chunk the array as the calculations are independent of each other.
# Note: an intermittent version made a distinction between 32- and 64 bit architectures
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if the note is necessary but also not opposed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is capturing a rationale from the past, so if you do not mind, I leave it.


# Call the classifier in chunks.
y_chunk_pos = 0
for x_chunk in np.array_split(X, np.arange(chunk_size,X_axis0_size,chunk_size,dtype=np.int32), axis=0):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please adhere to pep8? So spaces after , and not more than 79 chars per line.
But otherwise looks good, thank you!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thanks for the patience - I just should have "listened" to my IDE.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well thanks for being patient with my nit-picks ;)

Minor refinements due PR feedback
- Removed unnecessary variables and inlined one-time used variable.
- Re-introduced the originally intended solver solver='lbfgs'
- Adhered to PEP8, breaking lines and comments accordingly
@amueller
Copy link
Owner

awesome, thanks for your help :)

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