1

미리 정의 된 3D 함수에 맞게 MLPRegressor를 사용하려고합니다. 문제는 필자가 올바른 결과를 인쇄 할 수 없기 때문에 플롯 될 때 피팅이 끔찍한 것입니다.Python : MLPRegressor를 사용하여 3D 함수 적용

가 다음 함수 :

상기 플롯이 근사한다 무엇
def threeDFunc(xin,yin): 
    z = np.zeros((40,40)) 
    for xIndex in range(0,40,1): 
     for yIndex in range(0,40,1): 
      z[xIndex,yIndex]=(np.exp(-(xin[xIndex]**2+yin[yIndex]**2)/0.1)) 
    return z 



xThD = np.arange(-1,1,0.05) 
yThD = np.arange(-1,1,0.05) 
zThD = threeDFunc(xThD, yThD) 

3Dplot

.

3Dplot with approximation

빨간색은 무엇이다.

코드는 다음과 같습니다

classifier = neural_network.MLPRegressor(hidden_layer_sizes=(200, 200), activation='logistic', learning_rate='adaptive') 

xy = np.array((xThD.flatten(),yThD.flatten())) 

classifier.fit(np.transpose(xy), zThD) 

pre = classifier.predict(np.transpose(xy)) 

import pylab 
from mpl_toolkits.mplot3d import Axes3D 

fig = pylab.figure() 
ax = Axes3D(fig) 
X, Y = np.meshgrid(xThD, yThD) 
ax.plot_wireframe(X, Y, zThD) 
ax.plot_wireframe(X, Y, pre, color='red') 
print(np.shape(zThD)) 
print(np.shape(pre)) 
plt.show() 

답변

0

변경 activation='tanh'과 쌍곡선 황갈색 기능 활성화 기능과 solver='lbfgs'와 lbfgs에 해결사. 당신의 분류 인스턴스는 다음 보이는 경우에는 다음과 같이

, 빨간색과 파란색의 플롯은 거의 동일해야합니다 :

classifier = neural_network.MLPRegressor(hidden_layer_sizes=(200, 200), solver='lbfgs', activation='tanh', learning_rate='adaptive')