def add_area(self, name: str, n: int, k: int, beta: float) -> None: """Add an area to this brain, randomly connected to all other areas and stimulus. Initialize each synapse weight to have a value of 0 or 1 with probability 'p'. Initialize incoming and outgoing connectomes as empty arrays. Initialize incoming betas as 'beta'. Initialize outgoing betas as the target area.beta :param name: Name of area :param n: Number of neurons in the new area :param k: Number of winners in the new area :param beta: plasticity parameter of connectomes coming INTO this area. The plasticity parameter of connectomes FROM this area INTO other areas are decided by the betas of those other areas. """ self.areas[name] = Area(name, n, k, beta) # This should be replaced by conectomes_init_area(self, self.areas[name], beta). # (From here to the end of the function). for stim_name, stim_connectomes in self.stimuli_connectomes.items(): stim_connectomes[name] = np.empty( 0) # TODO: Should this be np.empty((0,0))? self.areas[name].stimulus_beta[stim_name] = beta new_connectomes: Dict[str, ndarray] = {} for key in self.areas: new_connectomes[key] = np.empty((0, 0)) if key != name: self.connectomes[key][name] = np.empty((0, 0)) self.areas[key].area_beta[name] = self.areas[key].beta self.areas[name].area_beta[key] = beta self.connectomes[name] = new_connectomes
Logger(base_path / 'log').__enter__() # Protect RAM from program using up all memory # Allows program to use only half of free memory protecc_ram(0.75) # Create graph for presenting the results fig, ax = plt.subplots() plt.title('Assemblies Merge') ax.set_xscale('log') plt.xlabel('t (Repeat Parameter)') plt.ylabel('Overlap %') # Create basic brain model stimulus = Stimulus(STIMULUS_SIZE) area1 = Area(AREA_SIZE) area2 = Area(AREA_SIZE) area3 = Area(AREA_SIZE) area4 = Area(AREA_SIZE) assembly1 = Assembly([stimulus], area1) assembly2 = Assembly([stimulus], area2) print(f"Writing simulation to {base_path}") begin_time = time.time() for merge_stabilization, repeats in TESTS: recipe = BrainRecipe(area1, area2, area3, area4, stimulus, assembly1, assembly2) # Define assembly out of recipe, # that way merge can done manually! assembly3 = (assembly1 + assembly2) >> area3