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()
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!
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)