# Supercollider: write and read MLP models

**URL:** <https://discourse.flucoma.org/t/supercollider-write-and-read-mlp-models/1318>\
**Category:** Usage Questions\
**Created:** [March 25, 2022, 5:24pm UTC](https://discourse.flucoma.org/t/supercollider-write-and-read-mlp-models/1318 "2022-03-25T17:24:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Erik](https://discourse.flucoma.org/letter_avatar_proxy/v4/letter/e/b5ac83/32.png) [@Erik](https://discourse.flucoma.org/u/Erik)\
**Post date:** [March 25, 2022, 5:24pm UTC](https://discourse.flucoma.org/t/supercollider-write-and-read-mlp-models/1318/1 "2022-03-25T17:24:28Z")

</div>

Hello all,

Might just be that I haven’t looked hard enough but I’m having trouble saving and restoring models created with the FluidMLPRegressor or FluidMLPClassifier in SuperCollider. The .write method seems to print the model to a file. I assumed I could restore the model with .read but got an error which refers to an ID, e.g. ‘ERROR: FluidMLPRegressor no instance with ID 4’. Am I on the right track here; is there any documentation on this that I have overlooked?

Cheers  
Erik

---

<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:** [March 25, 2022, 5:44pm UTC](https://discourse.flucoma.org/t/supercollider-write-and-read-mlp-models/1318/2 "2022-03-25T17:44:26Z")

</div>

Hi @Erik and welcome,

That _sounds_ like an error I thought we got rid of in the last release. Does the following fail for you?

```javascript
(
//just put anything into a dataset so we can 'fit' the MLP before writing
~ds = FluidDataSet(s);
~buf = Buffer.alloc(s,1,1);
~ds.setPoint(\1,~buf); 
//mlp1 we'll fit then save
~mlp1 = FluidMLPRegressor(s);
~mlp1.fit(~ds,~ds);
~mlp1.write("/tmp/mlptest.json"); 
//read into a 2nd mlp
~mlp2 = FluidMLPRegressor(s); 
~mlp2.read("/tmp/mlptest.json"); 
) 

```

and does this work?

```javascript
(
fork{
    //just put anything into a dataset so we can 'fit' the MLP before writing
    ~ds = FluidDataSet(s);
    s.sync; 
    ~buf = Buffer.alloc(s,1,1);
    ~ds.setPoint(\1,~buf); 
    //mlp1 we'll fit then save
    ~mlp1 = FluidMLPRegressor(s);
    s.sync; 
    ~mlp1.fit(~ds,~ds);
    ~mlp1.write("/tmp/mlptest.json"); 
    //read into a 2nd mlp
    ~mlp2 = FluidMLPRegressor(s); 
    s.sync; 
    ~mlp2.read("/tmp/mlptest.json"); 
}
) 

```

If so, maybe an update is indicated. If you do

```auto
FluidDataSet.version

```

it should print your version to the console: current is version 1.0.0-TB2.beta5

---

<div class="post-metadata">

**Author:** ![Erik](https://discourse.flucoma.org/letter_avatar_proxy/v4/letter/e/b5ac83/32.png) [@Erik](https://discourse.flucoma.org/u/Erik)\
**Post date:** [March 25, 2022, 8:34pm UTC](https://discourse.flucoma.org/t/supercollider-write-and-read-mlp-models/1318/3 "2022-03-25T20:34:25Z")

</div>

Hi Owen!  
Thanks a lot for this. Yes I did get errors in the first block of code but not the second. Also turns out I have version 1.0.0-TB2.beta4 so I need to update. However, I did get it to work by creating the instance first and then calling .read, rather than doing it all in one line.

Erik

---

<div class="post-metadata">

**Author:** ![Erik](https://discourse.flucoma.org/letter_avatar_proxy/v4/letter/e/b5ac83/32.png) [@Erik](https://discourse.flucoma.org/u/Erik)\
**Post date:** [March 25, 2022, 9:15pm UTC](https://discourse.flucoma.org/t/supercollider-write-and-read-mlp-models/1318/4 "2022-03-25T21:15:36Z")

</div>

All works fine after upgrade.
