tensorflow-js-maxmsp/tf.maxpat
2024-07-02 09:18:48 +02:00

820 lines
17 KiB
Plaintext

{
"patcher" : {
"fileversion" : 1,
"appversion" : {
"major" : 8,
"minor" : 6,
"revision" : 2,
"architecture" : "x64",
"modernui" : 1
}
,
"classnamespace" : "box",
"rect" : [ 44.0, 125.0, 1036.0, 622.0 ],
"bglocked" : 0,
"openinpresentation" : 0,
"default_fontsize" : 12.0,
"default_fontface" : 0,
"default_fontname" : "Arial",
"gridonopen" : 1,
"gridsize" : [ 15.0, 15.0 ],
"gridsnaponopen" : 1,
"objectsnaponopen" : 1,
"statusbarvisible" : 2,
"toolbarvisible" : 1,
"lefttoolbarpinned" : 0,
"toptoolbarpinned" : 0,
"righttoolbarpinned" : 0,
"bottomtoolbarpinned" : 0,
"toolbars_unpinned_last_save" : 0,
"tallnewobj" : 0,
"boxanimatetime" : 200,
"enablehscroll" : 1,
"enablevscroll" : 1,
"devicewidth" : 0.0,
"description" : "",
"digest" : "",
"tags" : "",
"style" : "",
"subpatcher_template" : "",
"assistshowspatchername" : 0,
"boxes" : [ {
"box" : {
"id" : "obj-44",
"maxclass" : "comment",
"numinlets" : 1,
"numoutlets" : 0,
"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" : 2,
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 199.0, 355.0, 50.0, 36.0 ],
"text" : "1 1 1 2 3"
}
}
, {
"box" : {
"id" : "obj-38",
"maxclass" : "newobj",
"numinlets" : 3,
"numoutlets" : 3,
"outlettype" : [ "", "", "" ],
"patching_rect" : [ 230.0, 325.0, 98.0, 22.0 ],
"text" : "route list weights"
}
}
, {
"box" : {
"id" : "obj-37",
"linecount" : 4,
"maxclass" : "comment",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 510.0, 97.0, 150.0, 62.0 ],
"text" : "Send a dictionary with weights and architecture prepended by \"set_weights\" to load"
}
}
, {
"box" : {
"id" : "obj-2",
"maxclass" : "newobj",
"numinlets" : 1,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 482.0, 192.0, 119.0, 22.0 ],
"text" : "prepend set_weights"
}
}
, {
"box" : {
"id" : "obj-31",
"maxclass" : "button",
"numinlets" : 1,
"numoutlets" : 1,
"outlettype" : [ "bang" ],
"parameter_enable" : 0,
"patching_rect" : [ 482.0, 130.0, 24.0, 24.0 ]
}
}
, {
"box" : {
"id" : "obj-27",
"linecount" : 3,
"maxclass" : "comment",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 676.0, 172.0, 150.0, 48.0 ],
"text" : "output a dictionary containing model architecture and weights"
}
}
, {
"box" : {
"id" : "obj-7",
"maxclass" : "dict.view",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 305.0, 382.0, 220.0, 214.0 ]
}
}
, {
"box" : {
"id" : "obj-21",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 676.0, 225.0, 86.0, 22.0 ],
"text" : "dump_weights"
}
}
, {
"box" : {
"id" : "obj-12",
"maxclass" : "newobj",
"numinlets" : 2,
"numoutlets" : 5,
"outlettype" : [ "dictionary", "", "", "", "" ],
"patching_rect" : [ 305.0, 355.0, 61.0, 22.0 ],
"saved_object_attributes" : {
"embed" : 0,
"legacy" : 0,
"parameter_enable" : 0,
"parameter_mappable" : 0
}
,
"text" : "dict"
}
}
, {
"box" : {
"id" : "obj-11",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 9.0, 185.0, 94.0, 22.0 ],
"text" : "script start 2 3 4"
}
}
, {
"box" : {
"id" : "obj-8",
"linecount" : 2,
"maxclass" : "comment",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 7.0, 134.0, 150.0, 34.0 ],
"text" : "0.5. Restart the main script"
}
}
, {
"box" : {
"data" : {
"weights" : [ {
"data" : {
"0" : -0.044006392359734,
"1" : 0.037017118185759,
"2" : -0.603930592536926,
"3" : 0.060808453708887,
"4" : 0.180193305015564,
"5" : 0.282816737890244,
"6" : 0.363093823194504,
"7" : 0.173229858279228
}
,
"shape" : [ 2, 4 ]
}
, {
"data" : {
"0" : 0,
"1" : 0,
"2" : 0,
"3" : 0
}
,
"shape" : [ 4 ]
}
, {
"data" : {
"0" : 0.224349781870842,
"1" : 0.860164880752563,
"2" : -0.442636489868164,
"3" : -0.214278265833855,
"4" : 0.491469591856003,
"5" : -0.450522541999817,
"6" : 0.438913941383362,
"7" : -0.085629880428314,
"8" : 0.372829973697662,
"9" : -0.778826951980591,
"10" : 0.724699020385742,
"11" : 0.034776996821165
}
,
"shape" : [ 4, 3 ]
}
, {
"data" : {
"0" : 0,
"1" : 0,
"2" : 0
}
,
"shape" : [ 3 ]
}
],
"model" : {
"class_name" : "Sequential",
"config" : {
"name" : "sequential_1",
"layers" : [ {
"class_name" : "Dense",
"config" : {
"units" : 4,
"activation" : "relu",
"use_bias" : 1,
"kernel_initializer" : {
"class_name" : "VarianceScaling",
"config" : {
"scale" : 1,
"mode" : "fan_avg",
"distribution" : "normal",
"seed" : null
}
}
,
"bias_initializer" : {
"class_name" : "Zeros",
"config" : {
}
}
,
"kernel_regularizer" : null,
"bias_regularizer" : null,
"activity_regularizer" : null,
"kernel_constraint" : null,
"bias_constraint" : null,
"name" : "dense_Dense1",
"trainable" : 1,
"batch_input_shape" : [ null, 2 ],
"dtype" : "float32"
}
}
, {
"class_name" : "Dense",
"config" : {
"units" : 3,
"activation" : "linear",
"use_bias" : 1,
"kernel_initializer" : {
"class_name" : "VarianceScaling",
"config" : {
"scale" : 1,
"mode" : "fan_avg",
"distribution" : "normal",
"seed" : null
}
}
,
"bias_initializer" : {
"class_name" : "Zeros",
"config" : {
}
}
,
"kernel_regularizer" : null,
"bias_regularizer" : null,
"activity_regularizer" : null,
"kernel_constraint" : null,
"bias_constraint" : null,
"name" : "dense_Dense2",
"trainable" : 1
}
}
]
}
,
"keras_version" : "tfjs-layers 4.20.0",
"backend" : "tensor_flow.js"
}
}
,
"id" : "obj-33",
"maxclass" : "newobj",
"numinlets" : 2,
"numoutlets" : 5,
"outlettype" : [ "dictionary", "", "", "", "" ],
"patching_rect" : [ 482.0, 161.0, 129.0, 22.0 ],
"saved_object_attributes" : {
"embed" : 1,
"legacy" : 0,
"parameter_enable" : 0,
"parameter_mappable" : 0
}
,
"text" : "dict myDict @embed 1"
}
}
, {
"box" : {
"id" : "obj-32",
"maxclass" : "comment",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 7.0, 18.0, 122.0, 20.0 ],
"text" : "0. Install tf package"
}
}
, {
"box" : {
"id" : "obj-30",
"linecount" : 4,
"maxclass" : "comment",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 491.0, 238.0, 150.0, 62.0 ],
"text" : "args are input shape, output shape, and size of the single hidden layer. Always Relu activation."
}
}
, {
"box" : {
"id" : "obj-28",
"linecount" : 2,
"maxclass" : "comment",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 339.0, 44.0, 152.0, 34.0 ],
"text" : "Uses basic SGD optimizer with 0.01 learning rate"
}
}
, {
"box" : {
"id" : "obj-26",
"maxclass" : "comment",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 547.0, 18.0, 150.0, 20.0 ],
"text" : "3. Run the trained model"
}
}
, {
"box" : {
"id" : "obj-24",
"maxclass" : "comment",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 339.0, 18.0, 150.0, 20.0 ],
"text" : "2. Train for 100k epochs"
}
}
, {
"box" : {
"id" : "obj-22",
"maxclass" : "comment",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 187.0, 25.0, 150.0, 20.0 ],
"text" : "1. Add training points"
}
}
, {
"box" : {
"id" : "obj-20",
"maxclass" : "button",
"numinlets" : 1,
"numoutlets" : 1,
"outlettype" : [ "bang" ],
"parameter_enable" : 0,
"patching_rect" : [ 204.0, 62.0, 24.0, 24.0 ]
}
}
, {
"box" : {
"id" : "obj-18",
"maxclass" : "newobj",
"numinlets" : 1,
"numoutlets" : 4,
"outlettype" : [ "bang", "bang", "bang", "bang" ],
"patching_rect" : [ 204.0, 101.0, 52.0, 22.0 ],
"text" : "t b b b b"
}
}
, {
"box" : {
"id" : "obj-17",
"maxclass" : "newobj",
"numinlets" : 1,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 204.0, 215.0, 112.0, 22.0 ],
"text" : "prepend data_point"
}
}
, {
"box" : {
"id" : "obj-16",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 266.0, 146.0, 55.0, 22.0 ],
"text" : "3 3 5 6 7"
}
}
, {
"box" : {
"id" : "obj-15",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 266.0, 170.0, 55.0, 22.0 ],
"text" : "4 4 7 8 9"
}
}
, {
"box" : {
"id" : "obj-14",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 204.0, 170.0, 55.0, 22.0 ],
"text" : "2 2 3 4 5"
}
}
, {
"box" : {
"id" : "obj-13",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 204.0, 146.0, 55.0, 22.0 ],
"text" : "1 1 1 2 3"
}
}
, {
"box" : {
"id" : "obj-9",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 560.0, 56.0, 65.0, 22.0 ],
"text" : "predict 5 5"
}
}
, {
"box" : {
"id" : "obj-4",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 351.0, 84.0, 75.0, 22.0 ],
"text" : "train 100000"
}
}
, {
"box" : {
"bgmode" : 0,
"border" : 0,
"clickthrough" : 0,
"enablehscroll" : 0,
"enablevscroll" : 0,
"id" : "obj-6",
"lockeddragscroll" : 0,
"lockedsize" : 0,
"maxclass" : "bpatcher",
"name" : "n4m.monitor.maxpat",
"numinlets" : 1,
"numoutlets" : 1,
"offset" : [ 0.0, 0.0 ],
"outlettype" : [ "bang" ],
"patching_rect" : [ 560.0, 353.0, 400.0, 220.0 ],
"viewvisibility" : 1
}
}
, {
"box" : {
"id" : "obj-5",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 7.0, 44.0, 98.0, 22.0 ],
"text" : "script npm install"
}
}
, {
"box" : {
"id" : "obj-1",
"maxclass" : "newobj",
"numinlets" : 1,
"numoutlets" : 2,
"outlettype" : [ "", "" ],
"patching_rect" : [ 230.0, 296.0, 287.0, 22.0 ],
"saved_object_attributes" : {
"args" : [ 2, 3, 4 ],
"autostart" : 1,
"defer" : 0,
"node_bin_path" : "",
"npm_bin_path" : "",
"watch" : 1
}
,
"text" : "node.script tf.js @watch 1 @autostart 1 @args 2 3 4"
}
}
],
"lines" : [ {
"patchline" : {
"destination" : [ "obj-38", 0 ],
"source" : [ "obj-1", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-6", 0 ],
"source" : [ "obj-1", 1 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-1", 0 ],
"source" : [ "obj-11", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-7", 0 ],
"source" : [ "obj-12", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-17", 0 ],
"source" : [ "obj-13", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-17", 0 ],
"source" : [ "obj-14", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-17", 0 ],
"source" : [ "obj-15", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-17", 0 ],
"source" : [ "obj-16", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-1", 0 ],
"source" : [ "obj-17", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-13", 0 ],
"source" : [ "obj-18", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-14", 0 ],
"source" : [ "obj-18", 1 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-15", 0 ],
"source" : [ "obj-18", 3 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-16", 0 ],
"source" : [ "obj-18", 2 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-1", 0 ],
"source" : [ "obj-2", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-18", 0 ],
"source" : [ "obj-20", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-1", 0 ],
"source" : [ "obj-21", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-33", 0 ],
"source" : [ "obj-31", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-2", 0 ],
"source" : [ "obj-33", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-1", 0 ],
"source" : [ "obj-35", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-12", 0 ],
"source" : [ "obj-38", 1 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-40", 1 ],
"source" : [ "obj-38", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-1", 0 ],
"source" : [ "obj-4", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-1", 0 ],
"source" : [ "obj-42", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-1", 0 ],
"source" : [ "obj-5", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-1", 0 ],
"source" : [ "obj-9", 0 ]
}
}
],
"dependency_cache" : [ {
"name" : "fit_jweb_to_bounds.js",
"bootpath" : "C74:/packages/Node for Max/patchers/debug-monitor",
"type" : "TEXT",
"implicit" : 1
}
, {
"name" : "n4m.monitor.maxpat",
"bootpath" : "C74:/packages/Node for Max/patchers/debug-monitor",
"type" : "JSON",
"implicit" : 1
}
, {
"name" : "resize_n4m_monitor_patcher.js",
"bootpath" : "C74:/packages/Node for Max/patchers/debug-monitor",
"type" : "TEXT",
"implicit" : 1
}
, {
"name" : "tf.js",
"bootpath" : "~/OneDrive/Documents/Max 8/tensorflow-max",
"patcherrelativepath" : ".",
"type" : "TEXT",
"implicit" : 1
}
],
"autosave" : 0
}
}