[英]python, neurolab, training step by step
給出來自neurolab的ANN
net = nl.net.newff([[0.0, 1.0]] * 5, [2])
我想迭代地訓練它,每K個時期執行驗證檢查。
盡管net.train()接受了epochs作為參數,但它的使用對我來說看起來很奇怪。 它以某種方式存儲了最后一個紀元(在網絡實例上?),因此以下將失敗並且“達到最大火車時代”並且不會繼續進行訓練。
for k in xrange(10):
net.train(training, target, epochs=1)
...do some checks
以下方法可行,但它會暴露計算開銷,因為它每次都會從頭開始。
for k in xrange(10):
net.train(training, target, epochs=k)
...do some checks
我錯過了什么? :)
#first
import neurolab as nl
#then
rep=10
i=0
#Number of inputs
numIN=5
#Number of neurons per layer
cap1=12
cap2=5
#Number of outputs
out=5
#create network
net = nl.net.newff([[-1, 1]]*numIN,[cap1,cap2,out])
while i<rep:
# I use train_bfgs is faster
#entradasu are the inputs and targetsu are the targets of your data
#then the network is adjusted in each iteration
error = nl.train.train_bfgs(net,entradasu, targetsu, epochs=1, show=0, goal=0.001)
#then do some checks
if checks==True:
i=rep
else
i+=1
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.