Exemplo n.º 1
0
    def __init__(self, weight: float = 1.0, mu: float = DEFAULT_ENERGY, sigma: float = DEFAULT_SIGMA,
                 listening_mode: ListeningMode = ListeningMode.MANUAL, moving_average_len: int = DEFAULT_MA_LEN):
        super().__init__()
        self.listen_to: Parameter = ParamWithSetter(listening_mode, 0, 2, "int",
                                                    "listen to (manual=0, external=1, feedback=2)",
                                                    self._set_listening_mode)
        self.moving_average_len: Parameter = Parameter(moving_average_len, 1, None, "int",
                                                       "num previous events to take into account if listening to input")
        self._weight: Parameter = Parameter(weight, None, None, 'float', "Relative weight of filter")
        self._mu: Parameter = ParamWithSetter(mu, None, None, 'float', "Mean value of gaussian.", self._set_mu)
        self._sigma: Parameter = Parameter(sigma, None, None, 'float', "Standard deviation of gaussian")

        self.history: deque[float] = deque([], self.moving_average_len.value)
Exemplo n.º 2
0
Arquivo: atom.py Projeto: DYCI2/Somax2
    def __init__(self,
                 name: str,
                 weight: float,
                 classifier: AbstractClassifier,
                 activity_pattern: AbstractActivityPattern,
                 memory_space: AbstractMemorySpace,
                 corpus: Corpus,
                 self_influenced: bool,
                 enabled: bool = True):
        super().__init__()
        self.logger = logging.getLogger(__name__)
        self.logger.debug(f"[__init__ Creating atom '{name}'.")
        self.name = name
        self._weight: Parameter = Parameter(weight, 0.0, None, 'float',
                                            "Relative scaling of atom peaks.")
        self._enabled: Parameter = ParamWithSetter(enabled, False, True,
                                                   "bool",
                                                   "Enables this Atom.",
                                                   self._set_enabled)

        self._classifier: AbstractClassifier = classifier
        self._memory_space: AbstractMemorySpace = memory_space
        self._activity_pattern: AbstractActivityPattern = activity_pattern
        self._self_influenced: Parameter = Parameter(
            self_influenced, 0, 1, 'bool',
            "Whether new events creates by player should influence this atom or not."
        )

        self._corpus: Optional[Corpus] = None
        if corpus:
            self.read_corpus(corpus)

        self._parse_parameters()
Exemplo n.º 3
0
    def __init__(self, taboo_length: int = DEFAULT_TABOO_LENGTH):
        super().__init__()
        self.logger = logging.getLogger(__name__)
        self._taboo_length: Parameter = ParamWithSetter(taboo_length, 1, None, 'int',
                                                        "Number of events to pass before event can be played again",
                                                        self._set_taboo_length)

        self._taboo_indices: deque[int] = deque([], self.taboo_length)
Exemplo n.º 4
0
 def __init__(self, history_len: int = 3, **_kwargs):
     super(NGramMemorySpace, self).__init__(**_kwargs)
     self.logger.debug(
         f"[__init__] Initializing {self.__class__.__name__} with history length {history_len}."
     )
     self._structured_data: Dict[Tuple[int, ...], List[CorpusEvent]] = {}
     self._ngram_size: Parameter = ParamWithSetter(
         history_len, 1, None, 'int',
         "Number of events to hard-match. (TODO)",
         self.set_ngram_size)  # TODO
     # history per transform stored with transform id as key
     self._influence_history: Dict[int, deque[int]] = {}
     self._parse_parameters()
Exemplo n.º 5
0
 def __init__(self, corpus: Corpus = None):
     super().__init__(corpus)
     self.logger.debug("[__init__]: ManualActivityPattern initialized.")
     self.extinction_threshold: Parameter = Parameter(
         0.1, 0.0, None, 'float', "Score below which peaks are removed")
     self.tau_mem_decay: Parameter = ParamWithSetter(
         self._calc_tau(self.DEFAULT_N), 1, None, "int",
         "Number of updates until peak is decayed below threshold.",
         self._set_tau)
     self.default_score: Parameter = Parameter(
         1.0, None, None, 'float', "Value of a new peaks upon creation.")
     self._peaks: Peaks = Peaks.create_empty()
     self.last_update_time: float = 0.0
     self._event_indices: np.ndarray = np.zeros(0, dtype=np.int32)
     self._parse_parameters()
Exemplo n.º 6
0
 def __init__(self,
              corpus: Corpus = None,
              tau_mem_decay: float = DEFAULT_T):
     super().__init__(corpus)
     self.logger.debug("[__init__]: ClassicActivityPattern initialized.")
     self.extinction_threshold: Parameter = Parameter(
         0.1, 0.0, None, 'float', "Score below which peaks are removed")
     # TODO: tau shouldn't be the parameter: t should
     self.tau_mem_decay: Parameter = ParamWithSetter(
         self._calc_tau(tau_mem_decay), 0, None, "float",
         "Number of updates until peak is decayed below threshold.",
         self._set_tau)
     self.default_score: Parameter = Parameter(
         1.0, None, None, 'float', "Value of a new peaks upon creation.")
     self._peaks: Peaks = Peaks.create_empty()
     self.last_update_time: float = 0.0
     self._parse_parameters()
Exemplo n.º 7
0
 def __init__(self):
     super().__init__()
     self._band_distribution: Parameter = ParamWithSetter(OctaveBandsScaleAction.DEFAULT_BAND_DISTRIBUTION, None,
                                                          None, "list[11]", "TODO", self._set_band_distribution)