Skip to content

PERF Get rid of intermediate array in binary_log_loss - #17932

Merged
thomasjpfan merged 1 commit into
scikit-learn:masterfrom
alexhenrie:sum
Jul 15, 2020
Merged

thomasjpfan merged 1 commit into
scikit-learn:masterfrom
alexhenrie:sum

Conversation

@alexhenrie

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

@rth rth left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice, thank you @alexhenrie !

@thomasjpfan thomasjpfan left a comment

Copy link
Copy Markdown
Member

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
@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.

3 participants