示例#1
0
    def normalize(self):
        if not self._objects:
            return

        if max(self._weights) > self._max_weight:
            self._decrease_all()

        while avg(self._weights) > self._average_weight:
            self._decrease_all()
示例#2
0
文件: store.py 项目: oleglite/syne
    def normalize(self):
        if not self._objects:
            return

        if max(self._weights) > self._max_weight:
            self._decrease_all()

        while avg(self._weights) > self._average_weight:
            self._decrease_all()
示例#3
0
def make_samples(threshold, message):
    assert message, "Message can't be empty"

    active_impulses = [
        [i for i, a in enumerate(row) if a >= threshold] + [None]
        for row in message.rows()
    ]

    for sample in product(*active_impulses):
        values = [message.get(y, x) if x is not None else 0 for y, x in enumerate(sample)]
        activity = avg(values)
        if activity:
            yield sample, activity
示例#4
0
文件: calc.py 项目: oleglite/syne
def similarity(it1, it2):
    return avg(int(x == y) for x, y in zip(it1, it2))
示例#5
0
文件: calc.py 项目: oleglite/syne
def similarity(it1, it2):
    return avg(int(x == y) for x, y in zip(it1, it2))