赞
踩
from sklearn.neural_network import MLPClassifier import numpy as np X = [[0., 0.], [1., 1.],[3,3]] y = [0, 1,2] clf = MLPClassifier(solver='lbfgs', alpha=1e-5, hidden_layer_sizes=(2,), random_state=1, activation='identity') clf.fit(X, y) print (clf.predict([[1.2,1]])) a = np.matrix(clf.coefs_[0]) b = np.matrix(clf.coefs_[1]) theta1 = np.matrix(clf.intercepts_[0]) theta1 = theta1.T theta2 = np.matrix(clf.intercepts_[1]) theta2 = theta2.T x=np.matrix([[1.2],[1]]) result = np.exp(b.T * (a.T*x+ theta1)+theta2) print (result/sum(result))
from sklearn.neural_network import MLPRegressor import numpy as np X = [[0., 0.], [1., 1.],[3,3]] y = [0., 1.,2.] clf = MLPRegressor(solver='lbfgs', alpha=1e-5,tol = 1e-6, hidden_layer_sizes=(2,), random_state=1, activation='identity') clf.fit(X, y) print (clf.predict([[3,3]])) a = np.matrix(clf.coefs_[0]) b = np.matrix(clf.coefs_[1]) theta1 = np.matrix(clf.intercepts_[0]) theta1 = theta1.T theta2 = np.matrix(clf.intercepts_[1]) theta2 = theta2.T x=np.matrix([[3.],[3.]]) result = b.T * (a.T*x+ theta1)+theta2
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。