本文整理汇总了Python中pybrain.datasets.SequentialDataSet.getNumSequences方法的典型用法代码示例。如果您正苦于以下问题:Python SequentialDataSet.getNumSequences方法的具体用法?Python SequentialDataSet.getNumSequences怎么用?Python SequentialDataSet.getNumSequences使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pybrain.datasets.SequentialDataSet
的用法示例。
在下文中一共展示了SequentialDataSet.getNumSequences方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SequentialDataSet
# 需要导入模块: from pybrain.datasets import SequentialDataSet [as 别名]
# 或者: from pybrain.datasets.SequentialDataSet import getNumSequences [as 别名]
dataSet = SequentialDataSet(inputLayerSize,outputLayerSize)
dataSet.newSequence()
for sample,next in zip(blob[0:sampleSize],cycle(blob[1:sampleSize+1])):
try:
if sample == ' ': dataSet.newSequence()
#print("creating Sample of:",sample,next)
actual = [0.0 for x in range(inputLayerSize)]
actual[wordToNum[sample]] = 1.0
expected = [0.0 for x in range(inputLayerSize)]
expected[wordToNum[next]] = 1.0
dataSet.appendLinked(actual,expected)
except KeyError as e:
print("Missing: ",str(e))
#print("Something went wrong for:",sample,next)
print("Data Set Created: ",dataSet.getNumSequences())
if False: #os.path.exists(networkSaveFile):
print("Loading Neural Network")
networkSave = codecs.open(networkSaveFile,'r','utf-8')
net = pickle.load(networkSave)
networkSave.close()
else:
#create the network
print("Creating Network: ",inputLayerSize,"->",hiddenLayerSize,"->",outputLayerSize)
net = buildNetwork(inputLayerSize,hiddenLayerSize,outputLayerSize,hiddenclass=LSTMLayer,outputbias=False,recurrent=True)
#create the trainer
print("Creating the trainer")
trainer = RPropMinusTrainer(net, dataset=dataSet)
train_errors = [] # save errors for plotting later