Skip to main content

Biological vision principles for efficient representation learning from natural images

Project description

💰 Support This Research - Please Donate!

🙏 If this library helps your research or project, please consider donating to support continued development:

💳 DONATE VIA PAYPAL - CLICK HERE

CI PyPI version Python 3.9+ License


Sparse Coding

💰 Biological vision principles for representation learning

Olshausen, B. A., & Field, D. J. (1996) - "Emergence of simple-cell receptive field properties"

📦 Installation

pip install sparse-coding

🚀 Quick Start

import sparse_coding
import numpy as np

# Create sample image patches (8x8 patches)
patches = np.random.randn(1000, 64)

# Initialize sparse coder
coder = sparse_coding.SparseCoder(
    dictionary_size=128,
    sparsity_lambda=0.1
)

# Learn sparse dictionary
coder.fit(patches)

# Encode new patches sparsely
test_patch = np.random.randn(1, 64)
sparse_code = coder.encode(test_patch)
reconstructed = coder.decode(sparse_code)

print(f"✅ Sparse coding: {np.sum(sparse_code != 0)} active out of {len(sparse_code)} atoms")
print(f"✅ Reconstruction error: {np.mean((test_patch - reconstructed)**2):.4f}")

🎓 About the Implementation

Implemented by Benedict Chen - bringing foundational AI research to modern Python.

📧 Contact: benedict@benedictchen.com

📖 Citation

If you use this implementation in your research, please cite the original paper:

Olshausen, B. A., & Field, D. J. (1996) - "Emergence of simple-cell receptive field properties"

📜 License

Custom Non-Commercial License with Donation Requirements - See LICENSE file for details.


💰 Support This Work - Donation Appreciated!

This implementation represents hundreds of hours of research and development. If you find it valuable, please consider donating:

💳 DONATE VIA PAYPAL - CLICK HERE

Your support helps maintain and expand these research implementations! 🙏

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

sparse_coding-1.1.0.tar.gz (29.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sparse_coding-1.1.0-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file sparse_coding-1.1.0.tar.gz.

File metadata

  • Download URL: sparse_coding-1.1.0.tar.gz
  • Upload date:
  • Size: 29.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3+

File hashes

Hashes for sparse_coding-1.1.0.tar.gz
Algorithm Hash digest
SHA256 b12f71f31f9bfb682f90a94e5fb6d6a4eb97e1349bf21c1601d50f0659c387f1
MD5 21faeb7a712151ac479da00601ef38e0
BLAKE2b-256 48f560473e8893fefb1fc288798b07b8851be98670a0f3b7e07d72d2ee50575f

See more details on using hashes here.

File details

Details for the file sparse_coding-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: sparse_coding-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3+

File hashes

Hashes for sparse_coding-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6358854f5d06e342642dfbf937364cd9da72cba06f977a4d54c6007be0fa1050
MD5 c5031fe56c420ca01800549edbd7aedc
BLAKE2b-256 823bf82fb83c6589b262d84fe69ad6941a7fbcfe8cbfd125e79afdaf193a59e9

See more details on using hashes here.

Supported by

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