-
Notifications
You must be signed in to change notification settings - Fork 3
/
exampleView.py
executable file
·52 lines (42 loc) · 1.53 KB
/
exampleView.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#! /usr/bin/env python
'''
This script wraps the SP Viewer so that you can tweak parameters easily.
Things to explore:
- Various Images (Image1-3 provided)
- The effect of Boosting
- The effect of increment and decrement sizes
- Changing the overlap percent on the patches the SP sees (0.0 - 1.0)
'''
from sp_viewer import SPViewer
from nupic.research.spatial_pooler import SpatialPooler
import pygame
def main():
# Instantiate our spatial pooler
sp = SpatialPooler(
inputDimensions = 32**2, # Size of image patch
columnDimensions = 16, # Number of potential features
potentialRadius = 10000, # Ensures 100% potential pool
potentialPct = 1, # Neurons can connect to 100% of input
globalInhibition = True,
numActiveColumnsPerInhArea = 1, # Only one feature active at a time
# All input activity can contribute to feature output
stimulusThreshold = 0,
synPermInactiveDec = 0.1,
synPermActiveInc = 0.1,
synPermConnected = 0.1, # Connected threshold
maxBoost = 3,
seed = 1956, # The seed that Grok uses
spVerbosity = 1)
viewer = SPViewer(sp,
screenWidth = 512,
screenHeight = 600,
imagePath = 'data/Image2.jpg',
patchSide = 32,
patchOverlapPercent = 0,
epochCount = 40,
replayDelay = .1)
viewer.run()
finalWindow = viewer.screen
pygame.image.save(finalWindow, "screenshot.jpg")
if __name__ == "__main__":
main()