当前位置: 首页>>代码示例>>Python>>正文


Python SequentialDataSet.getNumSequences方法代码示例

本文整理汇总了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
开发者ID:jgrey4296,项目名称:jgPyBrain_Exploration,代码行数:33,代码来源:v4.py


注:本文中的pybrain.datasets.SequentialDataSet.getNumSequences方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。