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

PERF Get rid of intermediate array in binary_log_loss #17932

Merged
merged 1 commit into from Jul 15, 2020

Conversation

alexhenrie
Copy link
Contributor

This decreases by about 10% the time required to train an example neural network from binary data. It also saves memory!

Test program:

from sklearn.datasets import load_digits
from sklearn.neural_network import MLPClassifier
from neurtu import delayed, Benchmark

digits = load_digits(return_X_y=True)
X = digits[0][:,:50].astype(bool).astype(int)
y = digits[0][:,50].astype(bool).astype(int)

clf = MLPClassifier(solver='lbfgs', alpha=1e-5,
                    hidden_layer_sizes=(50, 20), random_state=1, max_iter=1000)

train = delayed(clf).fit(X, y)
print(Benchmark(wall_time=True, cpu_time=True, repeat=5)(train))

Before:

      wall_time  cpu_time                                                                                                     
mean   8.084272  8.149094
max    8.106030  8.485355
std    0.016399  0.188559

After:

      wall_time  cpu_time                                                                                                     
mean   7.310994  7.283616
max    7.332577  7.296908
std    0.014912  0.014172

Copy link
Member

@rth rth left a comment

Choose a reason for hiding this comment

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

Nice, thank you @alexhenrie !

Copy link
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

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

The work you have done on the neural_network module has been great! @alexhenrie

LGTM!

@thomasjpfan thomasjpfan merged commit ccadf08 into scikit-learn:master Jul 15, 2020
5 checks passed
@alexhenrie alexhenrie deleted the sum branch October 5, 2020 15:04
jayzed82 pushed a commit to jayzed82/scikit-learn that referenced this pull request Oct 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants