本文整理汇总了Python中nupic.encoders.MultiEncoder.getScalars方法的典型用法代码示例。如果您正苦于以下问题:Python MultiEncoder.getScalars方法的具体用法?Python MultiEncoder.getScalars怎么用?Python MultiEncoder.getScalars使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nupic.encoders.MultiEncoder
的用法示例。
在下文中一共展示了MultiEncoder.getScalars方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Sensor
# 需要导入模块: from nupic.encoders import MultiEncoder [as 别名]
# 或者: from nupic.encoders.MultiEncoder import getScalars [as 别名]
#.........这里部分代码省略.........
QtGui.QMessageBox.warning(None, "Warning", "'" + self.name + "': Encoder size (" + str(encoderSize) + ") is different from sensor size (" + str(self.width) + " x " + str(self.height) + " = " + str(sensorSize) + ").", QtGui.QMessageBox.Ok)
return
return True
def nextStep(self):
"""
Performs actions related to time step progression.
"""
# Update states machine by remove the first element and add a new element in the end
for encoding in self.encodings:
encoding.currentValue.rotate()
if encoding.enableInference:
encoding.predictedValues.rotate()
encoding.bestPredictedValue.rotate()
Node.nextStep(self)
for bit in self.bits:
bit.nextStep()
# Get record value from data source
# If the last record was reached just rewind it
data = self.dataSource.getNextRecordDict()
if not data:
self.dataSource.rewind()
data = self.dataSource.getNextRecordDict()
# Pass raw values to encoder and get a concatenated array
outputArray = numpy.zeros(self.encoder.getWidth())
self.encoder.encodeIntoArray(data, outputArray)
# Get values obtained from the data source.
outputValues = self.encoder.getScalars(data)
# Get raw values and respective encoded bit array for each field
prevOffset = 0
for i in range(len(self.encodings)):
encoding = self.encodings[i]
# Convert the value to its respective data type
currValue = outputValues[i]
if encoding.encoderFieldDataType == FieldDataType.boolean:
currValue = bool(currValue)
elif encoding.encoderFieldDataType == FieldDataType.integer:
currValue = int(currValue)
elif encoding.encoderFieldDataType == FieldDataType.decimal:
currValue = float(currValue)
elif encoding.encoderFieldDataType == FieldDataType.dateTime:
currValue = dateutil.parser.parse(str(currValue))
elif encoding.encoderFieldDataType == FieldDataType.string:
currValue = str(currValue)
encoding.currentValue.setForCurrStep(currValue)
# Update sensor bits
for i in range(len(outputArray)):
if outputArray[i] > 0.:
self.bits[i].isActive.setForCurrStep(True)
else:
self.bits[i].isActive.setForCurrStep(False)
# Mark falsely predicted bits
for bit in self.bits:
if bit.isPredicted.atPreviousStep() and not bit.isActive.atCurrStep():
bit.isFalselyPredicted.setForCurrStep(True)