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

Method preprocess

bindsnet/environment/environment.py:205–220  ·  view source on GitHub ↗

Pre-processing step for an observation from a ``gym`` environment.

(self)

Source from the content-addressed store, hash-verified

203 self.env.close()
204
205 def preprocess(self) -> None:
206 # language=rst
207 """
208 Pre-processing step for an observation from a ``gym`` environment.
209 """
210 if self.name == "SpaceInvaders-v0":
211 self.obs = subsample(gray_scale(self.obs), 84, 110)
212 self.obs = self.obs[26:104, :]
213 self.obs = binary_image(self.obs)
214 elif self.name == "BreakoutDeterministic-v4":
215 self.obs = subsample(gray_scale(crop(self.obs, 34, 194, 0, 160)), 80, 80)
216 self.obs = binary_image(self.obs)
217 else: # Default pre-processing step.
218 pass
219
220 self.obs = torch.from_numpy(self.obs).float()
221
222 def update_history(self) -> None:
223 # language=rst

Callers 2

stepMethod · 0.95
resetMethod · 0.95

Calls 4

subsampleFunction · 0.90
gray_scaleFunction · 0.90
binary_imageFunction · 0.90
cropFunction · 0.90

Tested by

no test coverage detected