日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) >

【Python-ML】神经网络激励函数-Sigmoid

發(fā)布時(shí)間:2025/4/16 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【Python-ML】神经网络激励函数-Sigmoid 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
# -*- coding: utf-8 -*- ''' Created on 2018年1月27日 @author: Jason.F @summary: 前饋神經(jīng)網(wǎng)絡(luò)激勵(lì)函數(shù)-Sigmoid,邏輯斯蒂函數(shù) ''' import numpy as np import timeif __name__ == "__main__": start = time.clock() X= np.array([[1,1.4,1.5]])w=np.array([0.0,0.2,0.4])def net_input(X,w):z=X.dot(w)return zdef logistic(z):return 1.0/(1.0+np.exp(-z))def logistic_activation(X,w):z=net_input(X, w)return logistic(z)print ('P(y=1|x)=%.3f'%logistic_activation(X, w)[0])#W:array,shape=[n_output_units,n_hidden_units+1],weight matrix for hidden layer --> output layer#note that first column (A[:][0]=1) are the bias units.W=np.array([[1.1,1.2,1.3,0.5],[0.1,0.2,0.4,0.1],[0.2,0.5,2.1,1.9]])#A:array,shape=[n_hiddern+1,n_samples],Activation of hidden layer.#note that first element (A[0][0]=1) is the bias unit.A=np.array([[1.0],[0.1],[0.3],[0.7]])#Z:array,shape=[n_output_units,n_samples],Net input of the output layer.Z=W.dot(A)y_class = np.argmax(Z,axis=0)print ('predicted class label:%d'%y_class[0])end = time.clock() print('finish all in %s' % str(end - start))

結(jié)果:

P(y=1|x)=0.707 predicted class label:2 finish all in 0.00122912770087

總結(jié)

以上是生活随笔為你收集整理的【Python-ML】神经网络激励函数-Sigmoid的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。