Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Commit

Permalink
builds
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasvlevi committed Sep 5, 2021
1 parent f42b6c3 commit 0c202ed
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 69 deletions.
69 changes: 1 addition & 68 deletions build/dann.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const isBrowser = typeof process !== 'object';
const VERSION = 'v2.3.12';
const VERSION = 'v2.3.13';

/**
* Add a new custom function to Dannjs.
Expand Down Expand Up @@ -2254,73 +2254,6 @@ Dann.prototype.feed = function feed(inputs, options) {
return this.feedForward(inputs, options);
};

/**
* Applies a json object to a Dann model.
* @method fromJSON
* @for Dann
* @param {Object} data model data json object, you can get this object from a yourmodel.toJSON(); See docs <a href="https:/dannjs.org">here</a>.
* @return {Dann} A Dann model.
* @example
* <code>
* const nn = new Dann(24,4);
* nn.addHiddenLayer(18,'tanH');
* nn.addHiddenLayer(12,'sigmoid');
* nn.makeWeights();
* const modelData = nn.toJSON();
* const newNN = new Dann();
* newNN.fromJSON(modelData);
* newNN.log();
* </code>
*/
Dann.prototype.fromJSON = function fromJSON(data) {
this.i = data.arch[0];
this.inputs = new Matrix(this.i, 1);
this.o = data.arch[data.arch.length - 1];
this.outputs = new Matrix(this.o, 1);

let slayers = JSON.parse(data.lstr);
for (let i = 0; i < slayers.length; i++) {
let layerdata = JSON.parse(slayers[i]);
let layerObj = new Layer(layerdata.type, layerdata.size, layerdata.actname);
this.Layers[i] = layerObj;
}
this.makeWeights();
let sweights = JSON.parse(data.wstr);
for (let i = 0; i < sweights.length; i++) {
this.weights[i].set(JSON.parse(sweights[i]));
}
let sbiases = JSON.parse(data.bstr);
for (let i = 0; i < sbiases.length; i++) {
this.biases[i].set(JSON.parse(sbiases[i]));
}
let serrors = JSON.parse(data.estr);
for (let i = 0; i < serrors.length; i++) {
this.errors[i].set(JSON.parse(serrors[i]));
}
let sgradients = JSON.parse(data.gstr);
for (let i = 0; i < sgradients.length; i++) {
this.gradients[i].set(JSON.parse(sgradients[i]));
}

this.lossfunc_s = data.lf;
if (isBrowser) {
this.lossfunc = window[data.lf];
} else {
this.lossfunc = lossfuncs[data.lf];
}
this.outs = Matrix.toArray(this.Layers[this.Layers.length - 1].layer);
this.loss = data.loss;
this.losses = [];
this.lr = data.lrate;
this.arch = data.arch;
this.epoch = data.e;
this.percentile = data.per;
return this;
};
Dann.prototype.feed = function feed(inputs, options) {
return this.feedForward(inputs, options);
};

/**
* Applies a json object to a Dann model.
* @method fromJSON
Expand Down
Loading

0 comments on commit 0c202ed

Please sign in to comment.