本文整理汇总了Python中neuralnet.NeuralNet.trainer方法的典型用法代码示例。如果您正苦于以下问题:Python NeuralNet.trainer方法的具体用法?Python NeuralNet.trainer怎么用?Python NeuralNet.trainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类neuralnet.NeuralNet
的用法示例。
在下文中一共展示了NeuralNet.trainer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print
# 需要导入模块: from neuralnet import NeuralNet [as 别名]
# 或者: from neuralnet.NeuralNet import trainer [as 别名]
print("Building the Network")
ntwk = NeuralNet(nDims, nClasses, midlayer, midlayerargs, log_space)
print("Training the Network")
for epoch in range(nEpochs):
print('Epoch : ', epoch)
for samp in range(nSamples):
x = data_x[samp]
y = data_y[samp]
# if not samp % 500: print(samp)
if samp < nTrainSamples:
if log_space and len(y) < 2:
continue
cst, pred, aux = ntwk.trainer(x, y)
if (epoch % 10 == 0 and samp < 3) or np.isinf(cst):
print('\n## TRAIN cost: ', np.round(cst, 3))
show_all(y, x, pred, aux > 1e-20, 'Forward probabilities:')
if np.isinf(cst):
print('Exiting on account of Inf Cost...')
sys.exit()
elif (epoch % 10 == 0 and samp - nTrainSamples < 3) \
or epoch == nEpochs - 1:
# Print some test images
pred, aux = ntwk.tester(x)
aux = (aux + 1) / 2.0
print('\n## TEST')
show_all(y, x, pred, aux, 'Hidden Layer:')