SciPy 0.10 already has an implementation of the logistic function called
scipy.special.expit.
Using this makes RBM training 12% faster, as measured by observing the time
per iteration as reported by the plot_rbm_logistic_classification.py example,
disregarding the first iteration as an outlier (it's consistently faster than
the rest, not sure why). The speedup is in the expit function, not the
inplace operations; those are there to make benchmarking easier, but they
certainly won't hurt.
* check for NumPy >= 1.7.2 at import time, instead of in every call;
* save a function call when newer NumPy is available;
* rewrote documentation;
* put the docstring on fast_dot instead of _fast_dot;
* remove spurious warnings for matrix-vector multiplications (some of these
are suboptimal with older np.dot, but the good ones were triggering a
warning as well).
k-means can now use the memory-efficient dense implementation from
metrics.pairwise, while pairwise can use the fast sparse implementation
from k-means.
Timings, before:
>>> x = np.linspace(-1000, 1000, 10000)
>>> %timeit logistic_sigmoid(x)
1000 loops, best of 3: 570 us per loop
After:
>>> %timeit logistic_sigmoid(x)
1000 loops, best of 3: 286 us per loop
For comparison:
>>> %timeit np.tanh(x)
10000 loops, best of 3: 117 us per loop
>>> %timeit .5 * (1 + np.tanh(x/2.))
1000 loops, best of 3: 301 us per loop
TODO: optimize log_logistic_sigmoid.
Replaced all BSD style licenses with "BSD 3 clause"
Not checked yet!
Removed duplicate "3 clause, 3 clause"
Removed trailing period if exists
Fixed some missed licences, still about 50 to do, but those can be automated
Think I got the last of them.
Apparently me and sed have different ideas of regex.
Found a few more