A Python library for tensor operations powered by parallel processing.
Project description
TensorScout
A Python library for tensor operations powered by parallel processing.
Installation
pip install tensorscout
Contributors
- Andrew Garcia - creator and maintainer
Contributing
- Fork it (https://github.com/your-github-user/tensorscout/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Usage Example
import tensorscout as scout
import matplotlib.pyplot as plt
'''Performance comparison of a perforation algorithm using a single core (CPU) v. four cores in parallel'''
def perforate(tensor):
for i in range(10000):
cds = np.argwhere(tensor!=0)
tensor[tuple(cds[np.random.randint(cds.shape[0])])] = 0
return tensor
def perforateMP(tensor):
cores = 4
for i in range(int(10000/cores)):
cds = np.argwhere(tensor!=0)
tensor[tuple(cds[np.random.randint(cds.shape[0])])] = 0
return tensor
'''single processor (CPU)'''
A = np.ones((240,240))
A = perforate(A)
plt.imshow(A)
#%timeit perforate(np.ones((240,240)))
#5.23 s ± 9.99 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
'''parallel processing (4 CPUs)'''
A_MP = np.ones((240,240))
A_MP = scout.rebuild(scout.multi_core(A_MP, perforateMP, cores = 4))
plt.imshow(A_MP)
#%timeit scout.rebuild(scout.multi_core(np.ones((240,240)), perforateMP, cores = 4))
#745 ms ± 8.86 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
tensorscout-1.1.0.tar.gz
(2.8 kB
view hashes)
Built Distribution
Close
Hashes for tensorscout-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c226ea9d95757301ecd4bab7fda9986036326576521ac5e23ed51687ee1373d7 |
|
MD5 | 52630a798672182f79d4ba3e4d408ff9 |
|
BLAKE2b-256 | ae68d5b0e76f7bdce78f2517d26fd88be6fe98dd4dd8cc80918a4e48d75c7175 |