compileFromJSON
compileFromJSON(
json): (x,inputs?) =>object
Defined in: api.js:660
Rebuild a compiled objective from the data compile’s toJSON
produced, on this thread or another.
What comes back behaves like the output of compile, with one difference:
it has no objective function to fall back to, so it evaluates only at the
shapes it was built for and throws on any other. That is the point. A
worker cannot receive a closure, but it can receive this, and the data the
closure captured travels inside it as constant leaves; the data the closure
took as inputs is asked for again, by name, on every call.
Parameters
json
any
the value compiled.toJSON() returned
Returns
with .value(x, inputs) as on compile
(x, inputs?) => object
Example
const vg = compile(negLogLik);vg(p0); // builds the graphconst json = vg.toJSON(); // structured-clonableconst again = compileFromJSON(json); // in a worker, sayagain(p1); // same gradient the original gives