numpyを使用してニューラルフィールドをプログラミングしています。100*100ニューロンのマップの場合、10000*10000接続マップを管理する必要があります。
そこで、meshgridを使用して接続マップを作成し、MexicanHat関数の適応を適用しようとしています。ここに、試すことができるコードがあります。taille = 60
またはtaille = 70
(ニューラルマップの幅)を入力すると、機能します(私のPCでは問題ありません)が、を使用するとtaille = 100
、MemoryErrorが発生します。
import numpy as np
def connection_map4(width, se1, se2, K, inh):
x = np.arange(0, width**2, 1)
y = np.arange(0, width**2, 1)
X,Y = np.meshgrid(x, y)
print "Meshgrid cree"
A1 = 1.0 + inh
A2 = inh
# exp(|x-xc|/b + |y-yc|) -> Mexican Hat equation
# 2D/1D transformation relation: i = width.y + x
# ligne = (X/witdh - Y/width)**2
ligne = (X-Y)/width ## empirically, it's the division that doesn't pass.
print "avant carre"
ligne *= ligne
print "ligne"
colonne = (X%width-Y%width)**2
print "colonne"
M1 = A1*np.exp(-( (colonne)/(2*se1**2) + (ligne)/(2*se2**2) ) )
print "Premiere operation finie"
M2 = -A2*np.exp(-( (colonne)/(2*(K*se1)**2) + (ligne)/(2*(K*se2)**2) ) )
print "Seconde operation finie"
return(M1+M2)
taille = 100
connection_map4(taille, 7.5, 4.0, 2.0, 2.0)
経験的に、デバッグを何度か試した後、メッシュグリッドの各操作を分離しましたが、合格しないのは除算とモジュロのようです。
この分割を行うための解決策はありますか?ループを使用して計算を遅くしたくありません。