xxxx18一60岁hd中国/日韩女同互慰一区二区/西西人体扒开双腿无遮挡/日韩欧美黄色一级片 - 色护士精品影院www

  • 大小: 25KB
    文件類型: .zip
    金幣: 2
    下載: 2 次
    發(fā)布日期: 2021-07-20
  • 語言: Python
  • 標簽: bp??氣溫預(yù)測??

資源簡介

BP神經(jīng)網(wǎng)絡(luò)實現(xiàn)氣溫學習和預(yù)測代碼及代碼分析(python+tensflow),用python+tensflow實現(xiàn)氣溫的預(yù)測,本代碼包含數(shù)據(jù)集,不用重新下載,可以自行設(shè)置測試學習次數(shù),誤差范圍,點開導包,運行即可使用,并且附上了因版本不同,可能出現(xiàn)導包錯誤的解決方法。我實在是即穩(wěn)又貼心。

資源截圖

代碼片段和文件信息

import?tensorflow.compat.v1?as?tf
tf.disable_v2_behavior()
from?numpy.random?import?RandomState
import?pandas?as?pd
import?numpy?as?np
import?time

#定義神經(jīng)網(wǎng)絡(luò)的參數(shù)
d=3#輸入節(jié)點個數(shù)
l=1#輸出節(jié)點個數(shù)
q=2*d+1#隱層個數(shù)采用經(jīng)驗公式2d+1
train_num=480#訓練數(shù)據(jù)個數(shù)
test_num=240#測試數(shù)據(jù)個數(shù)
eta=0.5#學習率
error=0.0009#精度

#初始化權(quán)值和閾值
w1=?tf.Variable(tf.random.normal([d?q]?stddev=1?seed=1))#seed設(shè)定隨機種子,保證每次初始化相同數(shù)據(jù)
b1=tf.Variable(tf.constant(0.0shape=[q]))
w2=?tf.Variable(tf.random.normal([q?l]?stddev=1?seed=1))
b2=tf.Variable(tf.constant(0.0shape=[l]))

#輸入占位
x?=?tf.placeholder(tf.float32?shape=(None?d))#列數(shù)是d,行數(shù)不定
y_=?tf.placeholder(tf.float32?shape=(None?l))

#構(gòu)建圖:前向傳播
a=tf.nn.sigmoid(tf.matmul(xw1)+b1)#sigmoid激活函數(shù)
y=tf.nn.sigmoid(tf.matmul(aw2)+b2)
mse?=?tf.reduce_mean(tf.square(y_?-??y))#損失函數(shù)采用均方誤差
train_step?=?tf.train.AdamOptimizer(eta).minimize(mse)#Adam算法
#train_step?=?tf.train.GradientDescentOptimizer(eta).minimize(mse)#梯度下降法

#讀取氣溫數(shù)據(jù)
dataset?=?pd.read_csv(‘tem.csv‘?delimiter=““)
dataset=np.array(dataset)
mn=np.shape(dataset)
totalX=np.zeros((m-dd))
totalY=np.zeros((m-dl))
for?i?in?range(m-d):#分組:前三個值輸入,第四個值輸出
????totalX[i][0]=dataset[i][0]
????totalX[i][1]=dataset[i+1][0]
????totalX[i][2]=dataset[i+2][0]
????totalY[i][0]=dataset[i+3][0]
#歸一化數(shù)據(jù)
Normal_totalX=np.zeros((m-dd))
Normal_totalY=np.zeros((m-dl))
nummin=np.min(dataset)
nummax=np.max(dataset)
dif=nummax-nummin
for?i?in?range(m-d):
????for?j?in?range(d):
????????Normal_totalX[i][j]=(totalX[i][j]-nummin)/dif
????Normal_totalY[i][0]=(totalY[i][0]-nummin)/dif

#截取訓練數(shù)據(jù)
X=Normal_totalX[:train_num-d:]
Y=Normal_totalY[:train_num-d:]
testX=Normal_totalX[train_num::]
testY=totalY[train_num::]
start?=?time.clock()

#創(chuàng)建會話來執(zhí)行圖
with?tf.Session()?as?sess:
????init_op?=?tf.global_variables_initializer()#初始化節(jié)點
????sess.run(init_op)

????STEPS=0
????while?True:
????????sess.run(train_step?feed_dict={x:?X?y_:?Y})
????????STEPS+=1
????????train_mse=?sess.run(mse?feed_dict={x:?X?y_:?Y})
????????if?STEPS?%?10000?==?0:#每訓練100次,輸出損失函數(shù)
????????????print(“第?%d?次訓練后訓練集損失函數(shù)為:%g“?%?(STEPS?train_mse))
????????##if?train_mse????????##??break
????????if?STEPS>10000000:
??????????break

????print(“總訓練次數(shù):“STEPS)
????end?=?time.clock()
????print(“運行耗時(s):“end-start)

#測試
????Normal_y=?sess.run(y?feed_dict={x:?testX})#求得測試集下的y計算值
????DeNormal_y=Normal_y*dif+nummin#將y反歸一化
????test_mse=?sess.run(mse?feed_dict={y:?DeNormal_y?y_:?testY})#計算均方誤差
????print(“測試集均方誤差為:“test_mse)

#預(yù)測
????XX=tf.constant([[18.317.416.7]])
????XX=(XX-nummin)/dif#歸一化
????a=tf.nn.sigmoid(tf.matmul(XXw1)+b1)
????y=tf.nn.sigmoid(tf.matmul(aw2)+b2)
????y=y*dif+nummin#反歸一化
????print(“[18.317.416.7]輸入下預(yù)測氣溫為:“sess.run(y))

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2019-12-09?08:42??BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析(python+tensorflow)\
?????目錄???????????0??2019-12-08?10:10??BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析(python+tensorflow)\BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析%28python%2Btensorflow%29\
?????目錄???????????0??2019-12-08?13:27??BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析(python+tensorflow)\BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析%28python%2Btensorflow%29\BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析(python+tensorflow)\
?????目錄???????????0??2019-12-09?08:23??BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析(python+tensorflow)\BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析%28python%2Btensorflow%29\BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析(python+tensorflow)\.idea\
?????文件?????????441??2019-12-08?12:27??BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析(python+tensorflow)\BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析%28python%2Btensorflow%29\BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析(python+tensorflow)\.idea\BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析(python+tensorflow).iml
?????目錄???????????0??2019-12-08?10:13??BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析(python+tensorflow)\BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析%28python%2Btensorflow%29\BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析(python+tensorflow)\.idea\inspectionProfiles\
?????文件?????????174??2019-12-08?10:13??BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析(python+tensorflow)\BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析%28python%2Btensorflow%29\BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析(python+tensorflow)\.idea\inspectionProfiles\profiles_settings.xml
?????文件?????????294??2019-12-08?12:27??BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析(python+tensorflow)\BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析%28python%2Btensorflow%29\BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析(python+tensorflow)\.idea\misc.xml
?????文件?????????367??2019-12-08?10:13??BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析(python+tensorflow)\BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析%28python%2Btensorflow%29\BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析(python+tensorflow)\.idea\modules.xml
?????文件????????3758??2019-12-09?08:23??BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析(python+tensorflow)\BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析%28python%2Btensorflow%29\BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析(python+tensorflow)\.idea\workspace.xml
?????目錄???????????0??2019-12-08?12:26??BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析(python+tensorflow)\BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析%28python%2Btensorflow%29\BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析(python+tensorflow)\.ipynb_checkpoints\
?????文件??????????72??2019-12-08?12:26??BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析(python+tensorflow)\BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析%28python%2Btensorflow%29\BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析(python+tensorflow)\.ipynb_checkpoints\Untitled-checkpoint.ipynb
?????文件??????????72??2019-12-08?12:26??BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析(python+tensorflow)\BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析%28python%2Btensorflow%29\BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析(python+tensorflow)\Untitled.ipynb
?????文件????????3257??2019-12-08?13:27??BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析(python+tensorflow)\BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析%28python%2Btensorflow%29\BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析(python+tensorflow)\bpnn_tf.py
?????文件????????4153??2019-03-09?19:57??BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析(python+tensorflow)\BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析%28python%2Btensorflow%29\BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析(python+tensorflow)\tem.csv
?????文件???????????0??2019-12-08?10:17??BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析(python+tensorflow)\BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析%28python%2Btensorflow%29\BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析(python+tensorflow)\untitled
?????文件????????3015??2019-12-08?10:10??BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析(python+tensorflow)\BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析%28python%2Btensorflow%29.rar
?????文件???????12386??2019-12-09?08:42??BP神經(jīng)網(wǎng)絡(luò)實例及代碼分析(python+tensorflow)\因版本不同的報錯處理方法.docx

評論

共有 條評論

相關(guān)資源