Exemplo n.º 1
0
    def mmGetCellActivityPlot(self,
                              title=None,
                              showReset=False,
                              resetShading=0.25):
        """ Returns plot of the cell activity.
    @param title an optional title for the figure
    @param showReset if true, the first set of cell activities after a reset
                        will have a gray background
    @param resetShading If showReset is true, this float specifies the
    intensity of the reset background with 0.0 being white and 1.0 being black
    @return (Plot) plot
    """
        plot = Plot(self, title)
        resetTrace = self.mmGetTraceResets().data
        activeCellTrace = self._mmTraces["activeCells"].data
        data = numpy.zeros((self._numColumns, 1))
        for i in xrange(len(activeCellTrace)):
            if showReset and resetTrace[i]:
                activity = numpy.ones((self._numColumns, 1)) * resetShading
            else:
                activity = numpy.zeros((self._numColumns, 1))

            activeSet = activeCellTrace[i]
            activity[list(activeSet)] = 1
            data = numpy.concatenate((data, activity), 1)

        plot.add2DArray(data, xlabel="Time", ylabel="Cell Activity")
        return plot
  def mmGetPermanencesPlot(self, title=None):
    """ Returns plot of column permanences.
    @param title an optional title for the figure
    @return (Plot) plot
    """
    plot = Plot(self, title)

    data = numpy.zeros((self.getNumColumns(), self.getNumInputs()))
    for i in xrange(self.getNumColumns()):
      self.getPermanence(i, data[i])

    plot.add2DArray(data, xlabel="Permanences", ylabel="Column")
    return plot
  def mmGetPermanencesPlot(self, title=None):
    """ Returns plot of column permanences.
    @param title an optional title for the figure
    @return (Plot) plot
    """
    plot = Plot(self, title)

    data = numpy.zeros((self.getNumColumns(), self.getNumInputs()))
    for i in xrange(self.getNumColumns()):
      self.getPermanence(i, data[i])

    plot.add2DArray(data, xlabel="Permanences", ylabel="Column")
    return plot
  def mmGetPlotConnectionsPerColumn(self, title=None):
    """
    Returns plot of # connections per column.

    @return (Plot) plot
    """
    plot = Plot(self, title)
    plot.addGraph(sorted(self._connectedCounts.tolist(), reverse=True),
                  position=211,
                  xlabel="column", ylabel="# connections")
    plot.addHistogram(self._connectedCounts.tolist(),
                      position=212,
                      bins=len(self._connectedCounts) / 10,
                      xlabel="# connections", ylabel="# columns")
    return plot
Exemplo n.º 5
0
    def mmGetCellTracePlot(self,
                           cellTrace,
                           cellCount,
                           activityType,
                           title="",
                           showReset=False,
                           resetShading=0.25):
        """
    Returns plot of the cell activity. Note that if many timesteps of
    activities are input, matplotlib's image interpolation may omit activities
    (columns in the image).

    @param cellTrace    (list)   a temporally ordered list of sets of cell
                                 activities

    @param cellCount    (int)    number of cells in the space being rendered

    @param activityType (string) type of cell activity being displayed

    @param title        (string) an optional title for the figure

    @param showReset    (bool)   if true, the first set of cell activities
                                 after a reset will have a grayscale background

    @param resetShading (float)  applicable if showReset is true, specifies the
                                 intensity of the reset background with 0.0
                                 being white and 1.0 being black

    @return (Plot) plot
    """
        plot = Plot(self, title)
        resetTrace = self.mmGetTraceResets().data
        data = numpy.zeros((cellCount, 1))
        for i in xrange(len(cellTrace)):
            # Set up a "background" vector that is shaded or blank
            if showReset and resetTrace[i]:
                activity = numpy.ones((cellCount, 1)) * resetShading
            else:
                activity = numpy.zeros((cellCount, 1))

            activeIndices = cellTrace[i]
            activity[list(activeIndices)] = 1
            data = numpy.concatenate((data, activity), 1)

        plot.add2DArray(data, xlabel="Time", ylabel=activityType, name=title)
        return plot
Exemplo n.º 6
0
  def mmGetCellTracePlot(self, cellTrace, cellCount, activityType, title="",
                         showReset=False, resetShading=0.25):
    """
    Returns plot of the cell activity. Note that if many timesteps of
    activities are input, matplotlib's image interpolation may omit activities
    (columns in the image).

    @param cellTrace    (list)   a temporally ordered list of sets of cell
                                 activities

    @param cellCount    (int)    number of cells in the space being rendered

    @param activityType (string) type of cell activity being displayed

    @param title        (string) an optional title for the figure

    @param showReset    (bool)   if true, the first set of cell activities
                                 after a reset will have a grayscale background

    @param resetShading (float)  applicable if showReset is true, specifies the
                                 intensity of the reset background with 0.0
                                 being white and 1.0 being black

    @return (Plot) plot
    """
    plot = Plot(self, title)
    resetTrace = self.mmGetTraceResets().data
    data = numpy.zeros((cellCount, 1))
    for i in xrange(len(cellTrace)):
      # Set up a "background" vector that is shaded or blank
      if showReset and resetTrace[i]:
        activity = numpy.ones((cellCount, 1)) * resetShading
      else:
        activity = numpy.zeros((cellCount, 1))

      activeIndices = cellTrace[i]
      activity[list(activeIndices)] = 1
      data = numpy.concatenate((data, activity), 1)

    plot.add2DArray(data, xlabel="Time", ylabel=activityType)
    return plot
 def mmGetPlotUnionSDRDutyCycle(self, title="Union SDR Duty Cycle"):
   """
   @return (Plot) Plot of union SDR duty cycle.
   """
   plot = Plot(self, title)
   unionSDRDutyCycle = self.mmGetDataUnionSDRDutyCycle()
   plot.addGraph(sorted(unionSDRDutyCycle, reverse=True),
                 position=211,
                 xlabel="Union SDR Bit", ylabel="Duty Cycle")
   plot.addHistogram(unionSDRDutyCycle,
                     position=212,
                     bins=len(unionSDRDutyCycle) / 10,
                     xlabel="Duty Cycle", ylabel="# Union SDR Bits")
   return plot
  def mmGetPlotConnectionsPerColumn(self, title=None):
    """
    Returns plot of # connections per column.

    @return (Plot) plot
    """
    plot = Plot(self, title)
    plot.addGraph(sorted(self._connectedCounts.tolist(), reverse=True),
                  position=211,
                  xlabel="column", ylabel="# connections")
    plot.addHistogram(self._connectedCounts.tolist(),
                      position=212,
                      bins=len(self._connectedCounts) / 10,
                      xlabel="# connections", ylabel="# columns")
    return plot
 def mmGetPlotBitlife(self, title="Bitlife Statistics"):
   """
   @return (Plot) Plot of bitlife statistics.
   """
   plot = Plot(self, title)
   bitlife = self.mmGetDataBitlife()
   print bitlife
   plot.addGraph(sorted(bitlife, reverse=True),
                 position=211,
                 xlabel="Union SDR Bit", ylabel="Bitlife")
   plot.addHistogram(bitlife,
                     position=212,
                     bins=max(len(bitlife) / 10, 3),
                     xlabel="Bitlife", ylabel="# Union SDR Bits")
   return plot
 def mmGetPlotDistinctness(self, title="Distinctiness", showReset=False,
                           resetShading=0.25):
   """
   Returns plot of the overlap metric between union SDRs between sequences.
   @param title an optional title for the figure
   @return (Plot) plot
   """
   plot = Plot(self, title)
   self._mmComputeSequenceRepresentationData()
   data = self._mmData["distinctnessConfusion"]
   plot.addGraph(sorted(data, reverse=True),
                 position=211,
                 xlabel="Time steps", ylabel="Overlap")
   plot.addHistogram(data,
                     position=212,
                     bins=100,
                     xlabel="Overlap", ylabel="# time steps")
   return plot
  def mmGetPlotConnectionsPerColumn(self, title="Connections per Columns"):
    """
    Returns plot of # connections per column.

    @return (Plot) plot
    """
    plot = Plot(self, title)
    connectedCounts = numpy.ndarray(self.getNumColumns(), dtype=uintType)
    self.getConnectedCounts(connectedCounts)

    plot.addGraph(sorted(connectedCounts.tolist(), reverse=True),
                  position=211,
                  xlabel="column", ylabel="# connections")

    plot.addHistogram(connectedCounts.tolist(),
                      position=212,
                      bins=len(connectedCounts) / 10,
                      xlabel="# connections", ylabel="# columns")
    return plot