# Video: Quick n Dirty with MLPClassifier

**URL:** <https://discourse.flucoma.org/t/video-quick-n-dirty-with-mlpclassifier/900>\
**Category:** Learning Resources\
**Created:** [June 11, 2021, 8:57am UTC](https://discourse.flucoma.org/t/video-quick-n-dirty-with-mlpclassifier/900 "2021-06-11T08:57:42Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![weefuzzy](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/weefuzzy/32/362_2.png) [@weefuzzy](https://discourse.flucoma.org/u/weefuzzy)\
**Post date:** [June 11, 2021, 8:57am UTC](https://discourse.flucoma.org/t/video-quick-n-dirty-with-mlpclassifier/900/1 "2021-06-11T08:57:42Z")

</div>

Well, I say quick. The video’s still 50 min long 😬 Although maybe 25 of those are me saying ‘um’.

We do some audio matching starting from a very minimal setup and then explore a couple of things to improve it. Definitely of the wrap-it-in-gaffer-tape-until-it-works variety.

h/t @tedmoore for pointing out how little scaffolding was really needed to get going

https://player.vimeo.com/video/561582497

---

<div class="post-metadata">

**Author:** ![balintlaczko](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/balintlaczko/32/1184_2.png) [@balintlaczko](https://discourse.flucoma.org/u/balintlaczko)\
**Post date:** [June 11, 2021, 10:24am UTC](https://discourse.flucoma.org/t/video-quick-n-dirty-with-mlpclassifier/900/2 "2021-06-11T10:24:55Z")

</div>

I really like the big button. It is so convenient to click on, and the led is so big, I can be sure I won’t miss it when it flashes.

But seriously, thanks for the great presentation!! I especially liked the max-pooling part, will have to try it out. Honestly, when it got to the flickering-but-mostly-right level, I thought that’s it, that was my earlier experience of trying something similar with MuBu (though I probably did not use it right), and I also thought the relatively silent parts in 1 or 2 or the similar bass register in 2 or 3 will always result in those flickering predictions. I was quite surprised how dead-sure it got with max-pooling.  
I also liked that you pointed out the interactive training and playing with the `learnrate`. Will try that too next time.  
(And also, I had no idea about the `@carryflag` attribute of counter, although I have been annoyed by the default setting since I was a little boy. Now I see my life could have been so happy.)

By the way, what would you think about robustscaling instead of standardising in this context? As far as I understand robustscale scales the values so that there are less “gaps” in the range, but I don’t know if we want that for this purpose or if it would just add noise.

---

<div class="post-metadata">

**Author:** ![weefuzzy](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/weefuzzy/32/362_2.png) [@weefuzzy](https://discourse.flucoma.org/u/weefuzzy)\
**Post date:** [June 11, 2021, 10:44am UTC](https://discourse.flucoma.org/t/video-quick-n-dirty-with-mlpclassifier/900/3 "2021-06-11T10:44:34Z")

</div>

Thanks!

> [@balintlaczko](#):
>
> By the way, what would you think about robustscaling instead of standardising in this context? As far as I understand robustscale scales the values so that there are less “gaps” in the range, but I don’t know if we want that for this purpose or if it would just add noise.

In the general case I think it’s YMMV, and probably worth comparing results. Of course, actually looking at the distribution of values will help make a more informed choice: standardizing assumes that the data distribution is gaussian-enough not to produce nonsense, but outliers will tend to compress the bulk of the scaled data into a unhelpfully small range, and may well fail to centre the data well.

In this particular very dirty case, the samples are so small that the very idea of doing statistics on the data is slightly dodgy anyway: in a sense everything is an outlier! It’s quite possible that the RobustScaler would work better here though: definitely worth a shot. I guess a quick histogram abstraction to be able to inspect the distribution of features could be helpful, although at this scale it’s probably as easy just to swap out the scaler and compare.

---

<div class="post-metadata">

**Author:** ![jamesbradbury](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/jamesbradbury/32/1252_2.png) [@jamesbradbury](https://discourse.flucoma.org/u/jamesbradbury)\
**Post date:** [June 11, 2021, 11:46am UTC](https://discourse.flucoma.org/t/video-quick-n-dirty-with-mlpclassifier/900/4 "2021-06-11T11:46:39Z")

</div>

I see the video title, I see the patch and I’m already excited to get back into coding things again… will watch this evening!

---

<div class="post-metadata">

**Author:** ![balintlaczko](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/balintlaczko/32/1184_2.png) [@balintlaczko](https://discourse.flucoma.org/u/balintlaczko)\
**Post date:** [June 11, 2021, 1:38pm UTC](https://discourse.flucoma.org/t/video-quick-n-dirty-with-mlpclassifier/900/5 "2021-06-11T13:38:41Z")

</div>

> [@weefuzzy](#):
>
> the very idea of doing statistics on the data is slightly dodgy anyway: in a sense everything is an outlier!

Haven’t thought about that either, but it makes sense.

I am working on an abstraction that could hopefully make max-pooling more customizable on the training side (or for the query side for that matter). But not sure if my math checks out. I got inspired by your real-time “no-latency” max pooling on the query side, and I thought that the problem should be similar to an equal-temperament problem. My idea is to have a frame “decay” to X of its original value in exactly Y steps. I think this way we could control how “long” a certain frame should contribute to the result. Does this make sense?

Here is the patch.  
[frame-decay.zip](https://discourse.flucoma.org/uploads/short-url/AaosxlHEGQTUKdqtpfE4mCNsHcs.zip) (3.3 KB)

---

<div class="post-metadata">

**Author:** ![weefuzzy](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/weefuzzy/32/362_2.png) [@weefuzzy](https://discourse.flucoma.org/u/weefuzzy)\
**Post date:** [June 11, 2021, 2:42pm UTC](https://discourse.flucoma.org/t/video-quick-n-dirty-with-mlpclassifier/900/6 "2021-06-11T14:42:08Z")

</div>

That makes sense, and looks sensible. The way I normally get there is to start from the exponential case and then plug in the desired decay, i.e a coefficient _a_ = e(-1 / N) would decay its input to 1/e over N steps. Then if we had a different target, we’d say _a_ = e(ln(target)/N).

You’ve got _a_ = target(1/N) which might well turn out to be equivalent:  
=\>  
1/N = logtarget(_a_) = ln(_a_) / ln(target)  
ln(_a_) = ln(target) / N  
_a_ = e(ln(target) / N)

---

<div class="post-metadata">

**Author:** ![balintlaczko](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/balintlaczko/32/1184_2.png) [@balintlaczko](https://discourse.flucoma.org/u/balintlaczko)\
**Post date:** [June 11, 2021, 2:44pm UTC](https://discourse.flucoma.org/t/video-quick-n-dirty-with-mlpclassifier/900/7 "2021-06-11T14:44:00Z")

</div>

As an abstraction: `fluid.maxpool`. Critique is welcome.  
[fluid\_maxpool.zip](https://discourse.flucoma.org/uploads/short-url/vZEnfgdILyNiw2ejVkEUuBP5a2w.zip) (3.4 KB)

---

<div class="post-metadata">

**Author:** ![balintlaczko](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/balintlaczko/32/1184_2.png) [@balintlaczko](https://discourse.flucoma.org/u/balintlaczko)\
**Post date:** [June 11, 2021, 2:49pm UTC](https://discourse.flucoma.org/t/video-quick-n-dirty-with-mlpclassifier/900/8 "2021-06-11T14:49:24Z")

</div>

Thanks so much for the feedback!!

> [@weefuzzy](#):
>
> You’ve got _a_ = target(1/N) which might well turn out to be equivalent

I have to digest this, and I might not have enough IQ points to succeed. But feel free to check and modify the abstraction, I am really not that good in math… 😛

---

<div class="post-metadata">

**Author:** ![weefuzzy](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/weefuzzy/32/362_2.png) [@weefuzzy](https://discourse.flucoma.org/u/weefuzzy)\
**Post date:** [June 11, 2021, 3:00pm UTC](https://discourse.flucoma.org/t/video-quick-n-dirty-with-mlpclassifier/900/9 "2021-06-11T15:00:02Z")

</div>

Abstraction looks great: convenient and robust, and readable as well. Thanks!

@tremblap pointed out to me earlier today that max pooling probably only makes strict sense for nonnegative data, unless one tries to preserve the signs of the extrema. That looks a bit more fiddly to do in Max, but I might see if I can make a nice complement to this patcher.

---

<div class="post-metadata">

**Author:** ![balintlaczko](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/balintlaczko/32/1184_2.png) [@balintlaczko](https://discourse.flucoma.org/u/balintlaczko)\
**Post date:** [June 11, 2021, 3:04pm UTC](https://discourse.flucoma.org/t/video-quick-n-dirty-with-mlpclassifier/900/10 "2021-06-11T15:04:50Z")

</div>

> [@weefuzzy](#):
>
> max pooling probably only makes strict sense for nonnegative data

Yes I had the feeling too, since now anything will converge to 0. I guess you can offset the values with the detected all-time minimum, and then undo the offset on the output. But that’s hacky.

---

<div class="post-metadata">

**Author:** ![jamesbradbury](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/jamesbradbury/32/1252_2.png) [@jamesbradbury](https://discourse.flucoma.org/u/jamesbradbury)\
**Post date:** [June 11, 2021, 3:32pm UTC](https://discourse.flucoma.org/t/video-quick-n-dirty-with-mlpclassifier/900/11 "2021-06-11T15:32:13Z")

</div>

Okay, this is a side note but are you editing the breaks where you patch? Otherwise you have some unholy speed.

---

<div class="post-metadata">

**Author:** ![weefuzzy](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/weefuzzy/32/362_2.png) [@weefuzzy](https://discourse.flucoma.org/u/weefuzzy)\
**Post date:** [June 11, 2021, 3:37pm UTC](https://discourse.flucoma.org/t/video-quick-n-dirty-with-mlpclassifier/900/12 "2021-06-11T15:37:05Z")

</div>

Can’t it be both? (Yes, some of the of the more looming gaps, I just sped up the patching, and also on some of the training runs (but I actually 'fess up on screen to those))

---

<div class="post-metadata">

**Author:** ![jamesbradbury](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/jamesbradbury/32/1252_2.png) [@jamesbradbury](https://discourse.flucoma.org/u/jamesbradbury)\
**Post date:** [June 11, 2021, 3:39pm UTC](https://discourse.flucoma.org/t/video-quick-n-dirty-with-mlpclassifier/900/13 "2021-06-11T15:39:36Z")

</div>

Next time lie! I wanna live in a world where I know the fastest max patcher in existence

---

<div class="post-metadata">

**Author:** ![jamesbradbury](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/jamesbradbury/32/1252_2.png) [@jamesbradbury](https://discourse.flucoma.org/u/jamesbradbury)\
**Post date:** [June 11, 2021, 3:43pm UTC](https://discourse.flucoma.org/t/video-quick-n-dirty-with-mlpclassifier/900/14 "2021-06-11T15:43:54Z")

</div>

Just finished watching the video. I didn’t know about max pooling but it seems like you get really improved results although some added latency (shh @rodrigo.constanzo might hear).

> [@balintlaczko](#):
>
> My idea is to have a frame “decay” to X of its original value in exactly Y steps. I think this way we could control how “long” a certain frame should contribute to the result. Does this make sense?

Something like a spatial encoder could be of interest to you 🙂 there is one in the ml.\* package. I think that could be a cool way of imposing some form of “_memory_” and statefulness onto the training process perhaps.

---

<div class="post-metadata">

**Author:** ![balintlaczko](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/balintlaczko/32/1184_2.png) [@balintlaczko](https://discourse.flucoma.org/u/balintlaczko)\
**Post date:** [June 11, 2021, 4:34pm UTC](https://discourse.flucoma.org/t/video-quick-n-dirty-with-mlpclassifier/900/15 "2021-06-11T16:34:44Z")

</div>

How about this one?  
[fluid\_maxpool\_v2.zip](https://discourse.flucoma.org/uploads/short-url/eLAtZIyOOvHYC6Gvw9YaKAaqH4f.zip) (4.7 KB)  
Now it offsets to detected minimum, and undoes the offset on the output. Seems to work but not 100% sure.

> [@jamesbradbury](#):
>
> Something like a spatial encoder could be of interest to you

Thanks, James! I actually started out with that one, but then it didn’t feel clear how one would use it with lists.

I tried to recreate Owen’s patch with my fluid.maxpool abstraction. Something still might be a bit off, don’t know… But the maxpooling seems to have a good effect nevertheless.  
[owens\_mlpclassifier\_with\_maxpooling.zip](https://discourse.flucoma.org/uploads/short-url/vX5uytvk4AaQnRcYTPBWnLlNGsk.zip) (4.9 KB)

---

<div class="post-metadata">

**Author:** ![weefuzzy](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/weefuzzy/32/362_2.png) [@weefuzzy](https://discourse.flucoma.org/u/weefuzzy)\
**Post date:** [June 11, 2021, 11:22pm UTC](https://discourse.flucoma.org/t/video-quick-n-dirty-with-mlpclassifier/900/16 "2021-06-11T23:22:05Z")

</div>

Nice one! I think in the sampling you want to reset the pool when you press the bang, but also wait for the `@steps` frames before adding the point (which is why I had all that stuff with `bline`).

---

<div class="post-metadata">

**Author:** ![tremblap](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/tremblap/32/5_2.png) [@tremblap](https://discourse.flucoma.org/u/tremblap)\
**Post date:** [June 12, 2021, 10:59am UTC](https://discourse.flucoma.org/t/video-quick-n-dirty-with-mlpclassifier/900/17 "2021-06-12T10:59:34Z")

</div>

I have this dirty PoC for a bipolar max, but I have not tested it in the patch. It has the advantage of keeping the actual values, although once it’ll be all normalised it makes no difference whatsoever 😉

```

----------begin_max5_patcher----------
627.3ocwV9saaBCEF+Z3o3HTtHoifv1XBrK1KxTUEIwIiJhAAlrrU0284+.s
MqdoDEJSQAAGeLe7ye193mbc7VWdh03AeE9N337jqiiNjJfS2yNdGxNsoHqQ
ml2AVSS1dlmuoMA6jPGeIJDHvxXXItuspZVCiKxD4k7GJx4rMksbc13tLx2p
6a45GWhh56Fu8PNufIZdalxfksh9nndExDa9QNe+C0rMBCETZb.0GnoAg9Pb
j5JFGDB220EyaQ7qJlIeOO3dUKO65pt3eiCCq.DPgWFBdKfjwAvH7JETF.in
eV.xY+T9U+N9DPATXiNrU5PVoCeA6KLwvUnFrTkW9A34O1dnbpb.PBjSlCfn
.avhFIqjnMQJQ6nnz3od1JBvxEsQVPLcjHLE+5pwOuIq+K9BA8OK7kLN7EuR
uCCJF++a0Hr1BezqX4H4RKG0fgQF9BG.e9l+qy36GUVOxNUUCymsCA2Ay1gW
.eAlOGsTFXwcy1QVXYTvdMExUWSIrCe8dSnU3I1l+cATy1agO7ULK9Ba5FSM
SbSzfQRFnKO9ta15FkAu.9V2sXat5Hs6amqRL7hhHWqqpyyScvl+5DTZwTwO
ebnorsdS+qp+LOvqxsk0Hx45iK8ljnlbrNTOXgHSkP3AHjJGzXHD5CDRUm9l
UZHdTO12jPoSjGkLQVDcHCbi.OzALSHZj3AOfwsakmgrDJ5rukx5srZUqg21
ZpAJ7T.H5LS8E.Qua62rppir5ltdq0TVv4wRc5I95Gy4lG0EC7pYGy6yGYBk
UKKNHjUFZq0endmhMGcv6PoTYdadm3RbkZpqlwyjm5rJyPltnm6yt+QhhM26
-----------end_max5_patcher-----------

```

---

<div class="post-metadata">

**Author:** ![tremblap](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/tremblap/32/5_2.png) [@tremblap](https://discourse.flucoma.org/u/tremblap)\
**Post date:** [June 12, 2021, 11:00am UTC](https://discourse.flucoma.org/t/video-quick-n-dirty-with-mlpclassifier/900/18 "2021-06-12T11:00:33Z")

</div>

I also suggested to @weefuzzy that gating on the MFCC0 (a sort of loudness gate) to reset the thing would be even faster - again not tried.

Take home message for me: these videos are good to get discussions going 🙂

---

<div class="post-metadata">

**Author:** ![tutschku](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/tutschku/32/22_2.png) [@tutschku](https://discourse.flucoma.org/u/tutschku)\
**Post date:** [June 12, 2021, 2:43pm UTC](https://discourse.flucoma.org/t/video-quick-n-dirty-with-mlpclassifier/900/19 "2021-06-12T14:43:14Z")

</div>

> [@weefuzzy](#):
>
> Well, I say quick. The video’s still 50 min long 😬 Although maybe 25 of those are me saying ‘um’.

Great video. Thanks for taking the time to walk us through the entire patch making and all the musing about options, advantages and the pooling. Learned a lot!

---

<div class="post-metadata">

**Author:** ![tutschku](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/tutschku/32/22_2.png) [@tutschku](https://discourse.flucoma.org/u/tutschku)\
**Post date:** [June 12, 2021, 2:54pm UTC](https://discourse.flucoma.org/t/video-quick-n-dirty-with-mlpclassifier/900/20 "2021-06-12T14:54:07Z")

</div>

> [@balintlaczko](#):
>
> I tried to recreate Owen’s patch with my fluid.maxpool abstraction. Something still might be a bit off, don’t know… But the maxpooling seems to have a good effect nevertheless.  
> [owens\_mlpclassifier\_with\_maxpooling.zip](https://discourse.flucoma.org/uploads/short-url/vX5uytvk4AaQnRcYTPBWnLlNGsk.zip) (4.9 KB)

@balintlaczko thanks for the updated patch and the maxpool abstraction. Both are very helpful.

[Next page](https://discourse.flucoma.org/t/video-quick-n-dirty-with-mlpclassifier/900.md?page=2)
