def set_sparse_signals(self): """Set random sparse signals""" self.params_dSs = [self.mu_dSs, self.sigma_dSs] self.params_Ss0 = [self.mu_Ss0, self.sigma_Ss0] self.dSs, self.idxs = sparse_vector([self.Nn, self.Kk], self.params_dSs, seed=self.seed_dSs) # Ss0 is the ideal (learned) background stimulus without noise self.Ss0, self.Ss0_noisy = sparse_vector_bkgrnd([self.Nn, self.Kk], self.idxs, self.params_Ss0, seed=self.seed_Ss0) # The true signal, including background noise self.Ss = self.dSs + self.Ss0_noisy
def set_manual_signals(self): """ Set manually-selected sparse signals. """ params_dSs = [self.mu_dSs, self.sigma_dSs] params_Ss0 = [self.mu_Ss0, self.sigma_Ss0] self.idxs = self.manual_dSs_idxs self.dSs = manual_sparse_vector(self.Nn, self.manual_dSs_idxs, params_dSs, seed=self.seed_dSs) # Ss0 is the ideal (learned) background stimulus without noise self.Ss0, self.Ss0_noisy = sparse_vector_bkgrnd([self.Nn, self.Kk], self.manual_dSs_idxs, params_Ss0, seed=self.seed_Ss0) # The true signal, including background noise self.Ss = self.dSs + self.Ss0_noisy
def set_sparse_signals(self): """ Set random sparse signals """ params_dSs = [self.mu_dSs, self.sigma_dSs] params_Ss0 = [self.mu_Ss0, self.sigma_Ss0] self.dSs, self.idxs = sparse_vector([self.Nn, self.Kk], params_dSs, seed=self.seed_dSs) # Replace components with conflicting background odor if self.Kk_split is not None and self.Kk_split != 0: assert 0 <= self.Kk_split <= self.Kk, \ "Splitting sparse signal into two levels requires Kk_split" \ " to be non-negative and less than or equal to Kk." assert self.mu_dSs_2 is not None \ and self.sigma_dSs_2 is not None, \ "Splitting sparse signal into two levels requires that" \ " mu_dSs_2 and sigma_dSs_2 are set." sp.random.seed(self.seed_dSs) self.idxs_2 = sp.random.choice(self.idxs[0], self.Kk_split, replace=False) for idx_2 in self.idxs_2: self.dSs[idx_2] = sp.random.normal(self.mu_dSs_2, self.sigma_dSs_2) else: self.idxs_2 = [] self.Kk_split = 0 # Ss0 is the ideal (learned) background stimulus without noise self.Ss0, self.Ss0_noisy = sparse_vector_bkgrnd([self.Nn, self.Kk], self.idxs, params_Ss0, seed=self.seed_Ss0) self.Ss = self.dSs + self.Ss0_noisy
def set_sparse_signals(self): """ Set random sparse signals """ # Possibly override manual indices if self.manual_dSs_idxs is not None: self.set_manual_signals() return # Can override Kk_split with this; manually set compelxity of signal 2 if (self.Kk_1 is not None) and (self.Kk_2 is not None): self.Kk = self.Kk_1 + self.Kk_2 self.Kk_split = self.Kk_2 params_dSs = [self.mu_dSs, self.sigma_dSs] params_Ss0 = [self.mu_Ss0, self.sigma_Ss0] self.dSs, self.idxs = sparse_vector([self.Nn, self.Kk], params_dSs, seed=self.seed_dSs) # Replace components with conflicting background odor if (self.Kk_split is not None) and (self.Kk_split != 0): assert 0 <= self.Kk_split <= self.Kk, \ "Splitting sparse signal into two levels requires Kk_split" \ " to be non-negative and less than or equal to Kk." assert self.mu_dSs_2 is not None \ and self.sigma_dSs_2 is not None, \ "Splitting sparse signal into two levels requires that" \ " mu_dSs_2 and sigma_dSs_2 are set." if self.seed_dSs_2 is None: # Want both odor 1 and odor 2 to be determined by seed_dSs sp.random.seed(self.seed_dSs) self.idxs_2 = sp.random.choice(self.idxs[0], self.Kk_split, replace=False) else: # Want odor 1 and 2 to be determined by respective seeds. self.dSs, self.idxs = sparse_vector([self.Nn, self.Kk_1], params_dSs, seed=self.seed_dSs) _, self.idxs_2 = sparse_vector([self.Nn, self.Kk_split], params_dSs, seed=self.seed_dSs_2) # Re-define the full idxs and the odor 2 idxs subset self.idxs = ((list(self.idxs[0]) + list(self.idxs_2[0])), ) self.idxs_2 = self.idxs_2[0] for idx_2 in self.idxs_2: self.dSs[idx_2] = random_matrix( 1, params=[self.mu_dSs_2, self.sigma_dSs_2]) else: self.idxs_2 = [] self.Kk_split = 0 # Ss0 is the ideal (learned) background stimulus without noise self.Ss0, self.Ss0_noisy = sparse_vector_bkgrnd([self.Nn, self.Kk], self.idxs, params_Ss0, seed=self.seed_Ss0) self.Ss = self.dSs + self.Ss0_noisy