diff --git a/dann.js b/dann.js index 89256cd5..016bef2e 100644 --- a/dann.js +++ b/dann.js @@ -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) { @@ -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) { @@ -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'; @@ -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); @@ -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(""); diff --git a/package-lock.json b/package-lock.json index 02b7d93c..d5df5682 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "dannjs", - "version": "2.1.8d", + "version": "2.1.8e", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 471e9535..5b923639 100644 --- a/package.json +++ b/package.json @@ -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", @@ -49,7 +49,7 @@ "scripts": { "test": "danntest" }, - "version": "2.1.8d", + "version": "2.1.8e", "keywords": [ "dann", "js",