dump_data and clear_data

This commit is contained in:
trian-gles 2024-07-02 09:18:14 +02:00
parent 621422979a
commit ebecddde75
2 changed files with 71 additions and 17 deletions

11
tf.js
View File

@ -41,6 +41,17 @@ maxApi.addHandler("dataPoint", (...data) => {
ysArr.push(data.slice(inputShape)); ysArr.push(data.slice(inputShape));
}); });
maxApi.addHandler("clear_data", () => {
xsArr = [];
ysArr = [];
});
maxApi.addHandler("dump_data", () => {
for (let i=0; i<xsArr.length; i++) {
maxApi.outlet(xsArr[i].concat(ysArr[i]));
}
});
maxApi.addHandler("predict", (...data) => { maxApi.addHandler("predict", (...data) => {
data.map((item) => parseFloat(item)); data.map((item) => parseFloat(item));

View File

@ -40,25 +40,61 @@
"assistshowspatchername" : 0, "assistshowspatchername" : 0,
"boxes" : [ { "boxes" : [ {
"box" : { "box" : {
"id" : "obj-46", "id" : "obj-44",
"maxclass" : "newobj", "maxclass" : "comment",
"numinlets" : 1, "numinlets" : 1,
"numoutlets" : 0, "numoutlets" : 0,
"patching_rect" : [ 128.0, 434.0, 32.0, 22.0 ], "patching_rect" : [ 858.0, 270.0, 150.0, 20.0 ],
"text" : "print" "text" : "dump all training points"
}
}
, {
"box" : {
"id" : "obj-42",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 858.0, 296.0, 69.0, 22.0 ],
"text" : "dump_data"
}
}
, {
"box" : {
"id" : "obj-39",
"linecount" : 3,
"maxclass" : "comment",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 854.0, 175.0, 150.0, 48.0 ],
"text" : "clear all cached training data points (does not clear the weights)"
}
}
, {
"box" : {
"id" : "obj-35",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 858.0, 232.0, 65.0, 22.0 ],
"text" : "clear_data"
} }
} }
, { , {
"box" : { "box" : {
"id" : "obj-40", "id" : "obj-40",
"linecount" : 5, "linecount" : 2,
"maxclass" : "message", "maxclass" : "message",
"numinlets" : 2, "numinlets" : 2,
"numoutlets" : 1, "numoutlets" : 1,
"outlettype" : [ "" ], "outlettype" : [ "" ],
"patching_rect" : [ 199.0, 355.0, 50.0, 77.0 ], "patching_rect" : [ 199.0, 355.0, 50.0, 36.0 ],
"text" : "-2.7 -1.759611 3.244076" "text" : "1 1 1 2 3"
} }
} }
@ -117,7 +153,7 @@
"maxclass" : "comment", "maxclass" : "comment",
"numinlets" : 1, "numinlets" : 1,
"numoutlets" : 0, "numoutlets" : 0,
"patching_rect" : [ 654.0, 175.0, 150.0, 48.0 ], "patching_rect" : [ 676.0, 172.0, 150.0, 48.0 ],
"text" : "output a dictionary containing model architecture and weights" "text" : "output a dictionary containing model architecture and weights"
} }
@ -565,6 +601,8 @@
"args" : [ 2, 3, 4 ], "args" : [ 2, 3, 4 ],
"autostart" : 1, "autostart" : 1,
"defer" : 0, "defer" : 0,
"node_bin_path" : "",
"npm_bin_path" : "",
"watch" : 1 "watch" : 1
} }
, ,
@ -698,6 +736,13 @@
"source" : [ "obj-33", 0 ] "source" : [ "obj-33", 0 ]
} }
}
, {
"patchline" : {
"destination" : [ "obj-1", 0 ],
"source" : [ "obj-35", 0 ]
}
} }
, { , {
"patchline" : { "patchline" : {
@ -709,15 +754,6 @@
, { , {
"patchline" : { "patchline" : {
"destination" : [ "obj-40", 1 ], "destination" : [ "obj-40", 1 ],
"order" : 0,
"source" : [ "obj-38", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-46", 0 ],
"order" : 1,
"source" : [ "obj-38", 0 ] "source" : [ "obj-38", 0 ]
} }
@ -728,6 +764,13 @@
"source" : [ "obj-4", 0 ] "source" : [ "obj-4", 0 ]
} }
}
, {
"patchline" : {
"destination" : [ "obj-1", 0 ],
"source" : [ "obj-42", 0 ]
}
} }
, { , {
"patchline" : { "patchline" : {