Skip to main content

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

Contributing

  1. Fork it (https://github.com/your-github-user/tensorscout/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. 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)

Uploaded Source

Built Distribution

tensorscout-1.1.0-py3-none-any.whl (3.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page