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

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasvlevi committed Jan 2, 2021
1 parent 8d8fff7 commit 98f028e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
28 changes: 20 additions & 8 deletions dann.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let w;
function addCDNdependencies() {
let element = document.createElement('script');
element.setAttribute('type','text/javascript');
element.setAttribute('src','https://cdn.jsdelivr.net/npm/mathjs@8.1.0/lib/browser/math.min.js');
element.setAttribute('src','//https://cdn.jsdelivr.net/npm/mathjs@8.1.0/lib/browser/math.min.js');
document.head.insertBefore(element, document.head.children[0]);
}
if(!isBrowser) {
Expand Down Expand Up @@ -1005,7 +1005,7 @@ class Dann {
gdata[i] = JSON.stringify(this.gradients[i].matrix);
}
let g_str = JSON.stringify(gdata);
let dataOBJ = {wstr: w_str,lstr:l_str,bstr:b_str,estr:e_str,gstr:g_str,arch:this.arch,lrate:this.lr,lf:this.lossfunc_s,loss:this.loss};
let dataOBJ = {wstr: w_str,lstr:l_str,bstr:b_str,estr:e_str,gstr:g_str,arch:this.arch,lrate:this.lr,lf:this.lossfunc_s,loss:this.loss,e:this.epoch};

if (isBrowser) {

Expand Down Expand Up @@ -1071,10 +1071,6 @@ class Dann {
this.Layers[i].layer.addPrecent(randomFactor);
}
}
loadFromStr(str) {
let newNN = str;
applyToModel(this,newNN)
}
load(name, callback) {
if (!isBrowser) {
let path = './savedDanns/'+name+'/dannData.json';
Expand Down Expand Up @@ -1240,8 +1236,23 @@ function applyToModel(nn,newNN) {
let slayers = JSON.parse(newNN.lstr);
for (let i = 0; i < slayers.length; i++) {
let layerObj = JSON.parse(slayers[i]);
let layer = new Layer(layerObj.type,layerObj.size,layerObj.actname);
nn.Layers[i] = layer;

let act = layerObj.actname;
let der = act + '_d';
layerObj.actname = act;
layerObj.actname_d = der;
let func;
let func_d;
if (isBrowser) {
func = window[act];
func_d = window[der];
} else {
func = activations[act];
func_d = activations[der];
}
layerObj.actfunc = func;
layerObj.actfunc_d = func_d;
nn.Layers[i] = layerObj;
}
nn.makeWeights();
let sweights = JSON.parse(newNN.wstr);
Expand Down Expand Up @@ -1274,6 +1285,7 @@ function applyToModel(nn,newNN) {
nn.losses = [];
nn.lr = newNN.lrate;
nn.arch = newNN.arch;
nn.epoch = newNN.e;
nn.log();
if (isBrowser) {
console.log("");
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"_from": "dannjs",
"_id": "dannjs@2.1.8d",
"_id": "dannjs@2.1.8e",
"_inBundle": false,
"_integrity": "sha512-+Do7tE1EtLn/UMqyIy0V6dgLo43Wq6tj2vAY8oZTMHAY+ysYLJ2sT32H9DgZViL/B59XTIKN6BO8WEbn5pv8XA==",
"_location": "/dannjs",
Expand Down Expand Up @@ -49,7 +49,7 @@
"scripts": {
"test": "danntest"
},
"version": "2.1.8d",
"version": "2.1.8e",
"keywords": [
"dann",
"js",
Expand Down

0 comments on commit 98f028e

Please sign in to comment.