def inferObjectsWithRandomMovements(self):
    """
    Infer each object without any location input.
    """
    for objectName, objectFeatures in self.objects.iteritems():
      self.reset()

      inferred = False
      prevTouchSequence = None

      for _ in xrange(4):

        while True:
          touchSequence = list(objectFeatures)
          random.shuffle(touchSequence)

          if prevTouchSequence is not None:
            if touchSequence[0] == prevTouchSequence[-1]:
              continue

          break

        for i, feature in enumerate(touchSequence):
          locationOnObject = (feature["top"] + feature["height"]/2,
                              feature["left"] + feature["width"]/2)
          self.move(objectName, locationOnObject)

          featureName = feature["name"]
          featureSDR = self.features[featureName]
          self.sense(featureSDR, learn=False)

          inferred = (
            set(self.objectLayer.getActiveCells()) ==
            set(self.objectRepresentations[objectName]) and

            set(self.inputLayer.getActiveCells()) ==
            set(self.inputRepresentations[(objectName,
                                           locationOnObject,
                                           featureName)]) and

            set(self.getActiveLocationCells()) ==
            set(self.locationRepresentations[(objectName, locationOnObject)]))

          if inferred:
            break

        prevTouchSequence = touchSequence

        if inferred:
          break
def inferObjectsWithRandomMovements ( self ) : for objectName , objectFeatures in self . objects . iteritems ( ) : self . reset ( ) inferred = False prevTouchSequence = None for _ in xrange ( 4 ) : while True : touchSequence = list ( objectFeatures ) random . shuffle ( touchSequence ) if prevTouchSequence is not None : if touchSequence [ 0 ] == prevTouchSequence [ - 1 ] : continue break for i , feature in enumerate ( touchSequence ) : locationOnObject = ( feature [ "top" ] + feature [ "height" ] / 2 , feature [ "left" ] + feature [ "width" ] / 2 ) self . move ( objectName , locationOnObject ) featureName = feature [ "name" ] featureSDR = self . features [ featureName ] self . sense ( featureSDR , learn = False ) inferred = ( set ( self . objectLayer . getActiveCells ( ) ) == set ( self . objectRepresentations [ objectName ] ) and set ( self . inputLayer . getActiveCells ( ) ) == set ( self . inputRepresentations [ ( objectName , locationOnObject , featureName ) ] ) and set ( self . getActiveLocationCells ( ) ) == set ( self . locationRepresentations [ ( objectName , locationOnObject ) ] ) ) if inferred : break prevTouchSequence = touchSequence if inferred : break
Infer each object without any location input.