Exemplo n.º 1
0
        #numActiveColumnsPerInhArea = -1, # Using percentage instead
        numActiveColumnsPerInhArea=1,  # Only one feature active at a time
        # All input activity can contribute to feature output
        stimulusThreshold=0,
        synPermInactiveDec=0.3,
        synPermActiveInc=0.3,
        synPermConnected=0.3,  # Connected threshold
        maxBoost=2,
        seed=1956,  # The seed that Grok uses
        spVerbosity=1)

    # Instantiate the spatial pooler test bench.
    tb = VisionTestBench(sp)

    # Instantiate the classifier
    clf = exactMatch()

    # Train the spatial pooler on trainingVectors.
    numCycles = tb.train(trainingVectors, trainingTags, clf, maxTrainingCycles)

    # View the permanences and connections after training.
    tb.showPermsAndConns()
    #tb.savePermsAndConns('perms_and_conns.jpg')

    # Get testing images and convert them to vectors.
    testingImages, testingTags = data.getImagesAndTags(testingDataset)
    testingVectors = encoder.imagesToVectors(testingImages)

    # Test the spatial pooler on testingVectors.
    accuracy = tb.test(testingVectors, testingTags, clf, verbose=1)
Exemplo n.º 2
0
    #numActiveColumnsPerInhArea = -1, # Using percentage instead
    numActiveColumnsPerInhArea = 1, # Only one feature active at a time
    # All input activity can contribute to feature output
    stimulusThreshold = 0,
    synPermInactiveDec = 0.3,
    synPermActiveInc = 0.3,
    synPermConnected = 0.3, # Connected threshold
    maxBoost = 2,
    seed = 1956, # The seed that Grok uses
    spVerbosity = 1)

  # Instantiate the spatial pooler test bench.
  tb = VisionTestBench(sp)

  # Instantiate the classifier
  clf = exactMatch()

  # Train the spatial pooler on trainingVectors.
  numCycles = tb.train(trainingVectors, trainingTags, clf, maxTrainingCycles)

  # View the permanences and connections after training.
  tb.showPermsAndConns()
  #tb.savePermsAndConns('perms_and_conns.jpg')

  # Get testing images and convert them to vectors.
  testingImages, testingTags = data.getImagesAndTags(testingDataset)
  testingVectors = encoder.imagesToVectors(testingImages)

  # Test the spatial pooler on testingVectors.
  accuracy = tb.test(testingVectors, testingTags, clf, verbose=1)
Exemplo n.º 3
0
    clf = KNNClassifier()

    # Train the spatial pooler on trainingVectors.
    numCycles = tb.train(trainingVectors, trainingTags, clf, maxTrainingCycles,
                         minAccuracy)

    # Save the permanences and connections after training.
    #tb.savePermanences('perms.jpg')
    #tb.showPermanences()
    #tb.showConnections()

    # Get testing images and convert them to vectors.
    testingImages, testingTags = data.getImagesAndTags(testingDataset)
    testingVectors = encoder.imagesToVectors(testingImages)

    # Reverse the order of the vectors and tags for testing
    testingTags = [testingTag for testingTag in reversed(testingTags)]
    testingVectors = [
        testingVector for testingVector in reversed(testingVectors)
    ]

    # Test the spatial pooler on testingVectors.
    accuracy = tb.test(testingVectors, testingTags, clf)

    # Add results to the list
    parameters.appendResults([accuracy, numCycles])

parameters.printResults(["Percent Accuracy", "Training Cycles"],
                        [", %.2f", ", %d"])
print "The maximum number of training cycles is set to:", maxTrainingCycles
Exemplo n.º 4
0
# Instantiate the classifier
clf = KNNClassifier()

# Get training images and convert them to vectors.
trainingImages, trainingTags = data.getImagesAndTags(trainingDataset)
trainingVectors = encoder.imagesToVectors(trainingImages)

# Train the spatial pooler on trainingVectors.
numCycles = tb.train(trainingVectors, trainingTags, clf, maxTrainingCycles,
  minAccuracy)

# Save the permanences and connections after training.
#tb.savePermanences('perms.jpg')
#tb.showPermanences()
#tb.showConnections()

# Get testing images and convert them to vectors.
testingImages, testingTags = data.getImagesAndTags(testingDataset)
testingVectors = encoder.imagesToVectors(testingImages)

# Reverse the order of the vectors and tags for testing
testingTags = [testingTag for testingTag in reversed(testingTags)]
testingVectors = [testingVector for testingVector in reversed(testingVectors)]

# Test the spatial pooler on testingVectors.
accuracy = tb.test(testingVectors, testingTags, clf, learn=True)
print "Number of training cycles:", numCycles


Exemplo n.º 5
0
    # Instantiate the classifier
    clf = KNNClassifier()

    # Train the spatial pooler on trainingVectors.
    numCycles = tb.train(trainingVectors, trainingTags, clf, maxTrainingCycles,
      minAccuracy)

    # Save the permanences and connections after training.
    #tb.savePermanences('perms.jpg')
    #tb.showPermanences()
    #tb.showConnections()

    # Get testing images and convert them to vectors.
    testingImages, testingTags = data.getImagesAndTags(testingDataset)
    testingVectors = encoder.imagesToVectors(testingImages)

    # Reverse the order of the vectors and tags for testing
    testingTags = [testingTag for testingTag in reversed(testingTags)]
    testingVectors = [testingVector for testingVector in reversed(testingVectors)]

    # Test the spatial pooler on testingVectors.
    accuracy = tb.test(testingVectors, testingTags, clf)

    # Add results to the list
    parameters.appendResults([accuracy, numCycles])


  parameters.printResults(["Percent Accuracy", "Training Cycles"], [", %.2f", ", %d"])
  print "The maximum number of training cycles is set to:", maxTrainingCycles
Exemplo n.º 6
0
    tb = VisionTestBench(sp)

    # Train the spatial pooler on trainingVectors.
    trainSDRIs, numCycles = tb.train(trainingVectors, trainingTags,
      maxTrainingCycles, usePPM=False)

    # Save the permanences and connections after training.
    tb.savePermsAndConns('perms_and_conns.jpg')
    #tb.showPermsAndConns()

    # Get testing images and convert them to vectors.
    testingImages, testingTags = data.getImagesAndTags(testingDataset)
    testingVectors = encoder.imagesToVectors(testingImages)

    # Test the spatial pooler on testingVectors.
    testSDRIs = tb.test(testingVectors, testingTags)

    if testSDRIs != trainSDRIs:
      print "Yo! SDRs don't match!"
      #for i in range(len(testSDRIs)):
        #if testSDRIs[i] != trainSDRIs[i]:
          #print "%6s %6s %6s" % (i, trainSDRIs[i], testSDRIs[i])
          #tb.printSDR(trainSDRIs[i])
          #print
          #tb.printSDR(testSDRIs[i])
          #junk = raw_input()

    # Classifier Hack, uses the testing image tags along with the SDRs from the
    # last training cycle to interpret the SDRs from testing.
    testResults = []
    [testResults.append('') for i in range(len(testSDRIs))]