mimic-sussex / sema

Sema – A Playground for Live Coding Music and Machine Learning
https://sema.codes
MIT License
151 stars 51 forks source link

Errors when running models more than once. #321

Open smilo7 opened 3 years ago

smilo7 commented 3 years ago

Both errors occur when importing tensorflow JS then running a model.

To reproduce on https://sema.codes/tutorial/03-machine-learning/07-rl-gosling/

  1. Run live code (the code already in the window)
  2. Run step 1 then step 2 of the JS code.
  3. Run step 1 and then 2 of JS code again.

Errors then appear.

Error 1:

Eval exception on Learner:  Error: Variable with name dense_Dense1/kernel was already registered
    at e.t.makeVariable (VM5 tf.min.js:17)
    at qE (VM5 tf.min.js:17)
    at new e (VM5 tf.min.js:17)
    at t.n.addWeight (VM5 tf.min.js:17)
    at t.n.build (VM5 tf.min.js:17)
    at VM5 tf.min.js:17
    at AO (VM5 tf.min.js:17)
    at t.n.apply (VM5 tf.min.js:17)
    at t.n.add (VM5 tf.min.js:17)
    at Object.model.init (eval at gevalToConsole (6be94ec2-3b58-461d-9631-239a1a127aa7:366), <anonymous>:40:13)
gevalToConsole @ 6be94ec2-3b58-461d-9631-239a1a127aa7:371
onmessage @ 6be94ec2-3b58-461d-9631-239a1a127aa7:381

and

Error 2:

models.js:582 Uncaught (in promise) TypeError: Sequential model cannot be built: model is empty. Add some layers first.
    at t.n.build (VM5 tf.min.js:17)
    at t.n.predict (VM5 tf.min.js:17)
    at eval (eval at gevalToConsole (6be94ec2-3b58-461d-9631-239a1a127aa7:366), <anonymous>:67:22)
    at VM5 tf.min.js:17
    at e.t.scopedRun (VM5 tf.min.js:17)
    at e.t.tidy (VM5 tf.min.js:17)
    at Object.jI [as tidy] (VM5 tf.min.js:17)
    at Object.model.nextAction (eval at gevalToConsole (6be94ec2-3b58-461d-9631-239a1a127aa7:366), <anonymous>:66:16)
    at step (eval at gevalToConsole (6be94ec2-3b58-461d-9631-239a1a127aa7:366), <anonymous>:142:17)
    at input (eval at gevalToConsole (6be94ec2-3b58-461d-9631-239a1a127aa7:366), <anonymous>:193:31)

If live code is not run (skip step 1 of steps to reproduce) then then Error 1 is the only one to appear.