Skip to content

Commit

Permalink
cleaned
Browse files Browse the repository at this point in the history
  • Loading branch information
albertsalgueda committed Mar 31, 2022
1 parent 0df8030 commit ecc6a50
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ __pyscache__
.DS_Store
algorithm/__pyscache__
components/__pyscache__
visualization/__pyscache__
viz/__pyscache__
Binary file removed components/__pycache__/pooler.cpython-39.pyc
Binary file not shown.
Binary file removed components/__pycache__/sdr.cpython-39.pyc
Binary file not shown.
6 changes: 3 additions & 3 deletions components/encoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ def current_time(self):
return 'TODO'

class WordEncoder():
def __init__(self):
def __init__(self,size):
self.words = self.word2vec()

self.size = size
def word2vec(self):
#read word2vec file and save it as a dictionary
with open("assets/words.txt") as f:
Expand All @@ -40,7 +40,7 @@ def encode(self,word):

@classmethod
def transform(word):
#takes a word vector and turns into a SDR
#takes a word vector and turns into a SDR of (size,size)
#TODO
"""
array([ 0.120765, 0.066397, 0.173003, -0.457878, 0.268186, -0.023906,
Expand Down
2 changes: 1 addition & 1 deletion components/sdr.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def viz(sdr):
"""
Turn SDR into grid-like representation. We accept 2d numpy array
"""
colormap = colors.ListedColormap(["white","red"])
colormap = colors.ListedColormap(["black","red"])
pyplot.figure(figsize=(5,5))
pyplot.imshow(sdr,cmap=colormap)
pyplot.show()
Expand Down
6 changes: 5 additions & 1 deletion tester.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
"""
Use this document to test and experiment with the diferent components of the spatial pooler.py
"""

from components.sdr import viz,generate_sdr,overlap,overlap_score
from components.pooler import Connection,Neuron,Column,SpatialPool
from components.encoders import TimeEncoder, WordEncoder

potential_connections = .85 # % of potential connections
active_columns = 40 # number of
Expand All @@ -14,4 +16,6 @@
sparsity = .02
size = 64

sdr = viz(generate_sdr(size,sparsity))
sdr = viz(generate_sdr(size,sparsity))


Binary file removed viz/__pycache__/overlap.cpython-39.pyc
Binary file not shown.

0 comments on commit ecc6a50

Please sign in to comment.