import tensorflow as tf
import tflearn
import speech_data
learning_rate = 0.0001
training_iters = 3000 # steps
batch_size = 64
width = 20 # mfcc features
height = 80 # (max) length of utterance
classes = 10 # digits
batch = word_batch = speech_data.mfcc_batch_generator(batch_size)
# Network building
net = tflearn.input_data([None, width, height])
net = tflearn.lstm(net, 128*4, dropout=0.5)
net = tflearn.fully_connected(net, classes, activation='softmax')
net = tflearn.regression(net, optimizer='adam', learning_rate=learning_rate, loss='categorical_crossentropy')
model = tflearn.DNN(net, tensorboard_verbose=0)
## add this "fix" for tensorflow version errors
for x in tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES): tf.add_to_collection(tf.GraphKeys.VARIABLES, x )
# Training
while --training_iters > 0:
trainX, trainY = next(batch)
testX, testY = next(batch) # todo: proper ;)
model.fit(trainX, trainY, n_epoch=10, validation_set=(testX, testY), show_metric=True, batch_size=batch_size)
model.save("tflearn.lstm.model")
_y = model.predict(next(batch)[0]) # << add your own voice here
print (_y)
问题1:如果我在循环中运行此代码(而--training_iters&gt; 0 :)它永远不会停止,即使在3000步之后它仍然继续...为什么会这样..
我的问题是你如何获得输出,即如何开始预测..当我运行此代码时,我得到以下Output(在评论循环之后)..输出意味着什么..以及我如何预测数字。?
答案 0 :(得分:0)
删除while循环
while --training_iters> 0
并增加时代数