Skip to main content

minimal Python implementation of Caspian SNN processor

Project description

casPYan

A Python implementation of the Caspian SNN processor simulator.

Installation

pip install caspyan

Usage

import casPYan

Loading a Caspian network

# load a network from a json file
import json
with open("network.json") as f:
    network = json.load(f)

# Create a processor and load the network into it
processor = casPYan.Processor()
processor.load_network(network)

Setting up Encoders and Decoders

import casPYan.ende.rate as ende

# Create encoder and decoder arrays
encoders = [
    ende.RateEncoder(interval=10, domain=[0.0, 1.0])
    for _ in processor.inputs
]
decoders = [
    ende.RateDecoder(interval=10, domain=[0.0, 1.0])
    for _ in processor.outputs
]

Running a Caspian processor

input_vector = [0.5, 1.0]

# encode to spikes
spikes = [enc.get_spikes(x) for enc, x in zip(encoders, input_vector)]

# apply spikes
processor.apply_spikes(spikes)
# run processor for 10 ticks
processor.run(10)

# decode spikes to floats
data = [dec.decode(node.history) for dec, node in zip(decoders, processor.outputs)]

Saving a Caspian network

network = processor.to_tennlab()
with open("network.json", "w") as f:
    json.dump(network, f)

Creating a Caspian network from scratch

The low-level representation of a Caspian network is a list of nodes, along with a list of inputs and outputs that reference those nodes.

nodes = []

nodes.append(casPYan.Node(threshold=0.5, delay=0.0, leak=0.0))
nodes.append(casPYan.Node(threshold=1.0, delay=0.0, leak=0.0))

inputs = [nodes[0]]
outputs = [nodes[1]]

casPYan.connect(nodes[0], nodes[1], weight=0.5, delay=0)

casPYan.run(nodes, 10)

spikes = [node.history for node in outputs]

# saving and loading node representations
json_dict = casPYan.to_tennlab(nodes, inputs, outputs)
# json_dict is a Python dict that can be saved to a json file
# It is similar to what is loaded by casPYan.network_from_json
nodes, inputs, outputs = casPYan.network_from_json(json_dict)

See the following files for more low-level functions:

  • casPYan/node.py
  • casPYan/edge.py
  • casPYan/network.py

Disclaimer

This software does not guarantee the correctness of the simulation in relation to the original Caspian SNN simulator, Caspian processors, or any other software.

casPYan is not a substitute for the original software, and it is not supported by the original authors.

It should not be thought of as a port.

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

caspyan-0.2.2.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

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

caspyan-0.2.2-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file caspyan-0.2.2.tar.gz.

File metadata

  • Download URL: caspyan-0.2.2.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for caspyan-0.2.2.tar.gz
Algorithm Hash digest
SHA256 b48150f891b2edf1266420c11de7ee3b6204fd2f1a998aeef9bafd9fe88a668c
MD5 c68f6bccc15338d577507df55d765f39
BLAKE2b-256 f11923ef2bccf2ee83e0b56244d09dbfda8c4f953709c7197fe4b738a111c7d7

See more details on using hashes here.

Provenance

The following attestation bundles were made for caspyan-0.2.2.tar.gz:

Publisher: pypi-release.yml on GMU-ASRC/casPYan

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file caspyan-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: caspyan-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for caspyan-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ba4d2529003b528383a876ec917abf9d47f7e53a79d831c595838c55ba8bbefb
MD5 ff5c49e0054ff1c84d4db06ed9931855
BLAKE2b-256 54a26bd05dd808acfcd9fdd1f5a8dc25ef2cc8a55478cc86fcb43c7a3d1471ad

See more details on using hashes here.

Provenance

The following attestation bundles were made for caspyan-0.2.2-py3-none-any.whl:

Publisher: pypi-release.yml on GMU-ASRC/casPYan

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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