diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2019-12-26 16:51:01 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2019-12-26 16:51:01 +0100 |
| commit | d51c27cb238f5b0f885bea60e32dee6e2a619497 (patch) | |
| tree | 421aad4c4d706ad2b09f1bb5e0678116d9feb233 /inversion/live.py | |
| parent | a148a119fe4991a99e66ce6ae34c1cfed55e6605 (diff) | |
lerp to cat
Diffstat (limited to 'inversion/live.py')
| -rw-r--r-- | inversion/live.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/inversion/live.py b/inversion/live.py index 9e9c5c3..64f400d 100644 --- a/inversion/live.py +++ b/inversion/live.py @@ -125,9 +125,11 @@ class LerpParam: if self.n.value > 0.5: self.a.randomize() self.direction = -1 + return self.a else: self.b.randomize() self.direction = 1 + return self.b def update(self, dt): if self.direction != 0: @@ -238,6 +240,16 @@ class Interpolator: else: sys.stderr.write('{} not a valid option\n'.format(key)) + def set_category(self, category): + categories = " ".split(category) + label = np.zeros((BATCH_SIZE, N_CLASS,)) + ratio = 1 / len(categories) + target_param = self.lerp_params[payload].switch() + for category in categories: + index = int(category) + label[0, index] = ratio + target_param.assign(label) + def on_step(self, i, dt, sess): for param in self.sin_params.values(): param.update(dt) @@ -250,6 +262,8 @@ class Interpolator: print("Command: {} {}".format(cmd, payload)) if cmd == 'switch' and payload in self.lerp_params: self.lerp_params[payload].switch() + if cmd == 'setCategory': + self.set_category(payload) pass # -------------------------- |
