MCPcopy Create free account
hub / github.com/BindsNET/bindsnet / __init__

Method __init__

bindsnet/environment/dot_simulator.py:91–174  ·  view source on GitHub ↗
(self, t: int, **kwargs)

Source from the content-addressed store, hash-verified

89 """
90
91 def __init__(self, t: int, **kwargs) -> None:
92 self.timesteps = t # total timesteps
93 self.ts = 0 # initialize current timestep to 0
94
95 """ Keyword arguments """
96 self.h = kwargs.get("height", 28) # height dimension
97 self.w = kwargs.get("width", 28) # width dimension
98 self.decay = kwargs.get("decay", 1) # length of a dot's tail (path history)
99 self.ndots = kwargs.get("dots", 1) # Number of dots
100 self.herrs = kwargs.get("herrs", 0) # Red herrings (distractions)
101 self.pandas = kwargs.get("pandas", False) # print as pandas DF
102 self.write2F = kwargs.get("write", False) # write grids to file
103 self.mute = kwargs.get("mute", False) # mute displayed rendering
104 self.speed = kwargs.get("speed", 1) # dot movement speed
105 self.randr = kwargs.get("randr", 1.0) # rate of random movement
106 self.minch = int(not kwargs.get("allow_stay", True)) # allow stay choice.
107
108 # Grab system time and trim off extra large parts of the number.
109 sysTime = time()
110 sysTime = int(1e10 * (sysTime - 1e6 * (sysTime // 1e6)))
111
112 # Save off RNG seed.
113 self.seed = kwargs.get("seed", 0)
114 if self.seed == 0:
115 self.seed = sysTime
116
117 # Create filename if one isn't provided.
118 path = kwargs.get("fpath", "out")
119 self.filename = kwargs.get("fname", "grids_s" + str(self.seed) + ".csv")
120 self.fileCnt = 0
121 self.filename = (
122 path
123 + "/"
124 + self.filename[:-5]
125 + "_"
126 + str(self.fileCnt)
127 + self.filename[-4:]
128 )
129 if not os.path.exists(path):
130 os.makedirs(path)
131
132 # Expand movement options if diagonal is allowed.
133 if kwargs.get("diag", False):
134 self.choices = 9
135 else:
136 self.choices = 5
137
138 # Enumerated bounds handling when a dot traverses the region's edge.
139 bh = kwargs.get("bound_hand", "stay")
140 if bh == "stay":
141 self.b_handling = 0 # Don't move if directed past the edge.
142 elif bh == "bounce":
143 self.b_handling = 1 # Bounce off edge (reflect coordinates).
144 elif bh == "trans":
145 self.b_handling = 2 # Translate to opposite side of the region.
146 else:
147 assert False, "Unsupported bounds handling"
148

Callers

nothing calls this directly

Calls 2

DotClass · 0.85
getMethod · 0.45

Tested by

no test coverage detected