DEV Community

Dominik Bálló
Dominik Bálló

Posted on

here is a 3d spiking neural network created in PyNN running on nest simulator

import pyNN.nest as sim
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

# Szimuláció inicializálása
sim.setup()

# Neuronok létrehozása
num_neurons = 100
neurons = sim.Population(num_neurons, sim.IF_cond_exp())

# Neuronok pozícióinak beállítása
positions = np.random.rand(num_neurons, 3) * 10  # 3D pozíciók generálása
neurons.positions = positions.T  # Transzponálás a megfelelő alakra

# Szinapszisok létrehozása
connector = sim.FixedNumberPreConnector(n=10)
synapse = sim.StaticSynapse(weight=0.1, delay=1.0)
projection = sim.Projection(neurons, neurons, connector, synapse)

# Szimuláció futtatása
sim.run(1000.0)

# Vizualizáció
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.scatter(positions[:, 0], positions[:, 1], positions[:, 2], c='b', marker='o')

# Szinapszisok vizualizálása
connections = projection.get(['weight', 'delay'], format='list')
for conn in connections:
    pre_idx, post_idx, weight, delay = conn
    pre_pos = positions[int(pre_idx)]  # Indexek átalakítása egész számokká
    post_pos = positions[int(post_idx)]  # Indexek átalakítása egész számokká
    ax.plot([pre_pos[0], post_pos[0]], [pre_pos[1], post_pos[1]], [pre_pos[2], post_pos[2]], 'k-', alpha=0.1)

ax.set_xlabel('X tengely')
ax.set_ylabel('Y tengely')
ax.set_zlabel('Z tengely')
plt.show()

# Szimuláció lezárása
sim.end()
Enter fullscreen mode Exit fullscreen mode

Image description

Heroku

Built for developers, by developers.

Whether you're building a simple prototype or a business-critical product, Heroku's fully-managed platform gives you the simplest path to delivering apps quickly — using the tools and languages you already love!

Learn More

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

If this post resonated with you, feel free to hit ❤️ or leave a quick comment to share your thoughts!

Okay