dump_data and clear_data
This commit is contained in:
parent
621422979a
commit
ebecddde75
11
tf.js
11
tf.js
@ -41,6 +41,17 @@ maxApi.addHandler("dataPoint", (...data) => {
|
||||
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) => {
|
||||
data.map((item) => parseFloat(item));
|
||||
|
77
tf.maxpat
77
tf.maxpat
@ -40,25 +40,61 @@
|
||||
"assistshowspatchername" : 0,
|
||||
"boxes" : [ {
|
||||
"box" : {
|
||||
"id" : "obj-46",
|
||||
"maxclass" : "newobj",
|
||||
"id" : "obj-44",
|
||||
"maxclass" : "comment",
|
||||
"numinlets" : 1,
|
||||
"numoutlets" : 0,
|
||||
"patching_rect" : [ 128.0, 434.0, 32.0, 22.0 ],
|
||||
"text" : "print"
|
||||
"patching_rect" : [ 858.0, 270.0, 150.0, 20.0 ],
|
||||
"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" : {
|
||||
"id" : "obj-40",
|
||||
"linecount" : 5,
|
||||
"linecount" : 2,
|
||||
"maxclass" : "message",
|
||||
"numinlets" : 2,
|
||||
"numoutlets" : 1,
|
||||
"outlettype" : [ "" ],
|
||||
"patching_rect" : [ 199.0, 355.0, 50.0, 77.0 ],
|
||||
"text" : "-2.7 -1.759611 3.244076"
|
||||
"patching_rect" : [ 199.0, 355.0, 50.0, 36.0 ],
|
||||
"text" : "1 1 1 2 3"
|
||||
}
|
||||
|
||||
}
|
||||
@ -117,7 +153,7 @@
|
||||
"maxclass" : "comment",
|
||||
"numinlets" : 1,
|
||||
"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"
|
||||
}
|
||||
|
||||
@ -565,6 +601,8 @@
|
||||
"args" : [ 2, 3, 4 ],
|
||||
"autostart" : 1,
|
||||
"defer" : 0,
|
||||
"node_bin_path" : "",
|
||||
"npm_bin_path" : "",
|
||||
"watch" : 1
|
||||
}
|
||||
,
|
||||
@ -698,6 +736,13 @@
|
||||
"source" : [ "obj-33", 0 ]
|
||||
}
|
||||
|
||||
}
|
||||
, {
|
||||
"patchline" : {
|
||||
"destination" : [ "obj-1", 0 ],
|
||||
"source" : [ "obj-35", 0 ]
|
||||
}
|
||||
|
||||
}
|
||||
, {
|
||||
"patchline" : {
|
||||
@ -709,15 +754,6 @@
|
||||
, {
|
||||
"patchline" : {
|
||||
"destination" : [ "obj-40", 1 ],
|
||||
"order" : 0,
|
||||
"source" : [ "obj-38", 0 ]
|
||||
}
|
||||
|
||||
}
|
||||
, {
|
||||
"patchline" : {
|
||||
"destination" : [ "obj-46", 0 ],
|
||||
"order" : 1,
|
||||
"source" : [ "obj-38", 0 ]
|
||||
}
|
||||
|
||||
@ -728,6 +764,13 @@
|
||||
"source" : [ "obj-4", 0 ]
|
||||
}
|
||||
|
||||
}
|
||||
, {
|
||||
"patchline" : {
|
||||
"destination" : [ "obj-1", 0 ],
|
||||
"source" : [ "obj-42", 0 ]
|
||||
}
|
||||
|
||||
}
|
||||
, {
|
||||
"patchline" : {
|
||||
|
Loading…
Reference in New Issue
Block a user