我正在实施一种算法,该算法建议了一种新的人工神经网络方法(如果您想查看的话,请参考:Ghiassi,Manoochehr和H. Saidane。“一种用于人工神经网络的动态体系结构。”神经计算63( 2005):397-413)。
我运行了代码,并且运行了一个多小时,没有任何错误或结果。您能帮我确定原因吗?
我使用GPU,TPU和无在Google colaboratory上运行了代码。我还使用了Kaggle Kernels,我寻找了无限循环,但似乎什么也没找到。看起来一切都很好,但没有带来结果。
#### Training the model ####
# Initialization
a0 = b00 = b01 = a = b = c = d = 0
epsilon = 0.001
mse_best = 10^(6)
mse_target = np.exp(-50)
layer_num = 0
Forecast = []
angmatr = []
# Initial linear layer
Model = LinearRegression().fit(InputData,OutputData)
a0 = Model.intercept_
A0 = a0*np.ones(np.shape(InputData)[0])
F0 = A0 + np.dot(InputData,Model.coef_)
mse = mean_squared_error(OutputData,F0)
if(mse < mse_best):
mse_best = mse
# Save the architecture
coef = []
coef.append(a0)
for i in range(len(Model.coef_)):
coef.append(Model.coef_[i])
O = []
O.append(coef)
Forecast = F0
F1 = F0
for i in range(np.shape(InputData)[0]):
X = np.array(InputData[i][:]).reshape(-1,1)
Cosine = np.dot(R,X)/(np.linalg.norm(R)*np.linalg.norm(X))
angle = np.arccos(Cosine)
angmatr.append(angle)
# Compute hidden layer(s)
while (mse_best > mse_target) :
µ = 1
µ_best = 0
layer_num += 1
while (µ < µ_max) & (mse_best > mse_target):
G = []
H = []
for i in range(len(angmatr)):
angle = angmatr[i]
G.extend(np.cos(µ*angle))
H.extend(np.sin(µ*angle))
Input = np.asarray([F1,G,H]).T
Model = LinearRegression().fit(Input,OutputData)
a = Model.intercept_
A = a*np.ones(np.shape(InputData)[0])
F = A + np.dot(Input,Model.coef_)
F1 = F
coef = []
coef.append(a)
for i in range(len(Model.coef_)):
coef.append(Model.coef_[i])
mse = mean_squared_error(OutputData,F)
if(mse < mse_best):
mse_best = mse
µ_best = µ
Forecast = F
else:
µ = µ + epsilon
O.append(coef)
DAN2_model = O
我希望在“ DAN2_model”变量中找到网络各层的节点系数,并在“ layer_num”变量中找到生成的层数。
提前谢谢