Giter Club home page Giter Club logo

Comments (19)

Leekao avatar Leekao commented on August 20, 2024

Would it help if I pasted the JSON file?

from synaptic.

cazala avatar cazala commented on August 20, 2024

@Leekao I just tested the toJSON/fromJSON methods and they are working for me, maybe your JSON file is corrupted?

from synaptic.

Leekao avatar Leekao commented on August 20, 2024

did you test them after writing and reading to file? it works for me too if I don't write and read the JSON.

from synaptic.

cazala avatar cazala commented on August 20, 2024

then it seems that the problem is either when storing the json file or when loading its content, can you console.log the json right before calling Network.fromJSON() and share it?

from synaptic.

Leekao avatar Leekao commented on August 20, 2024

Not right now :(
I was so excited to continue with development that I designed a hack that seems to be working, Instead of saving the entire network to JSON I just save an object with the state and bias for each of the neurons in the hidden layers and when I'm loading I'm building a new network and overwrite the hidden layers with the data I got from the stored object.
this seems to be working perfectly.
btw: the Synaptic project is awesome and thank you so much for sharing it with the world.

from synaptic.

cazala avatar cazala commented on August 20, 2024

thank you, I'm glad you liked the project (: if your network doesn't have recurrent connections, storing only the hidden layer might work, but be careful because on other architectures (like LSTM) you will lose some relevant data like eligibility traces and extended eligibility traces, which will affect the network's context information (short term memory)

from synaptic.

Leekao avatar Leekao commented on August 20, 2024

Yeah, I thought I might but I'm not designing a learning network, I'm creating random neural networks and let them play poker against each other and everytime one of them loses I create a new random network to replace him using parts from the winner, I'm trying to reach a poker-playing AI through sheer evolution.

from synaptic.

Leekao avatar Leekao commented on August 20, 2024

@cazala Sorry for re-opening but I was not satisfied with my last solution so I tried saving the network.toJSON to mongodb and got the same problem as in with writing to file.
this is the json I'm trying to make a neural network from:

{"neurons":[{"trace":{"elegibility":{"1430":0,"1431":0,"1432":0,"1433":0,"1434":0},"extended":{}},"state":0,"old":0,"activation":0,"bias":-0.0934673140756786,"layer":"input","squash":"LOGISTIC"},{"trace":{"elegibility":{"1430":0,"1431":0,"1432":0,"1433":0,"1434":0},"extended":{}},"state":0,"old":0,"activation":0,"bias":0.0494202553294599,"layer":"input","squash":"LOGISTIC"},{"trace":{"elegibility":{"1430":0,"1431":0,"1432":0,"1433":0,"1434":0},"extended":{}},"state":0,"old":0,"activation":0,"bias":0.04499146621674299,"layer":"input","squash":"LOGISTIC"},{"trace":{"elegibility":{"1430":0,"1431":0,"1432":0,"1433":0,"1434":0},"extended":{}},"state":0,"old":0,"activation":0,"bias":-0.08561813430860639,"layer":"input","squash":"LOGISTIC"},{"trace":{"elegibility":{"1430":0,"1431":0,"1432":0,"1433":0,"1434":0},"extended":{}},"state":0,"old":0,"activation":0,"bias":0.02037893678061664,"layer":"input","squash":"LOGISTIC"},{"trace":{"elegibility":{"1430":0,"1431":0,"1432":0,"1433":0,"1434":0},"extended":{}},"state":0,"old":0,"activation":0,"bias":0.04538926533423365,"layer":"input","squash":"LOGISTIC"},{"trace":{"elegibility":{"1430":0,"1431":0,"1432":0,"1433":0,"1434":0},"extended":{}},"state":0,"old":0,"activation":0,"bias":-0.04428912154398859,"layer":"input","squash":"LOGISTIC"},{"trace":{"elegibility":{"1430":0,"1431":0,"1432":0,"1433":0,"1434":0},"extended":{}},"state":0,"old":0,"activation":0,"bias":0.08125061094760896,"layer":"input","squash":"LOGISTIC"},{"trace":{"elegibility":{"1430":0,"1431":0,"1432":0,"1433":0,"1434":0},"extended":{}},"state":0,"old":0,"activation":0,"bias":0.0352629475761205,"layer":"input","squash":"LOGISTIC"},{"trace":{"elegibility":{"1430":0,"1431":0,"1432":0,"1433":0,"1434":0},"extended":{}},"state":0.18694771779701114,"old":0,"activation":0,"bias":0.04695777939632534,"layer":"0","squash":"LOGISTIC"},{"trace":{"elegibility":{"1430":0,"1431":0,"1432":0,"1433":0,"1434":0},"extended":{}},"state":0.6175163022708148,"old":0,"activation":0,"bias":0.051773940213024616,"layer":"0","squash":"LOGISTIC"},{"trace":{"elegibility":{"1430":0,"1431":0,"1432":0,"1433":0,"1434":0},"extended":{}},"state":0.4381595221348107,"old":0,"activation":0,"bias":-0.026980691123753786,"layer":"0","squash":"LOGISTIC"},{"trace":{"elegibility":{"1430":0,"1431":0,"1432":0,"1433":0,"1434":0},"extended":{}},"state":0.7914434939157218,"old":0,"activation":0,"bias":-0.019196726754307752,"layer":"0","squash":"LOGISTIC"},{"trace":{"elegibility":{"1430":0,"1431":0,"1432":0,"1433":0,"1434":0},"extended":{}},"state":0.26838883734308183,"old":0,"activation":0,"bias":-0.03186677508056164,"layer":"0","squash":"LOGISTIC"},{"trace":{"elegibility":{"1430":0,"1431":0,"1432":0,"1433":0,"1434":0},"extended":{}},"state":0.18694771779701114,"old":0,"activation":0,"bias":0.04695777939632534,"layer":"1","squash":"LOGISTIC"},{"trace":{"elegibility":{"1430":0,"1431":0,"1432":0,"1433":0,"1434":0},"extended":{}},"state":0.6175163022708148,"old":0,"activation":0,"bias":0.051773940213024616,"layer":"1","squash":"LOGISTIC"},{"trace":{"elegibility":{"1430":0,"1431":0,"1432":0,"1433":0,"1434":0},"extended":{}},"state":0.4381595221348107,"old":0,"activation":0,"bias":-0.026980691123753786,"layer":"1","squash":"LOGISTIC"},{"trace":{"elegibility":{"1430":0,"1431":0,"1432":0,"1433":0,"1434":0},"extended":{}},"state":0.7914434939157218,"old":0,"activation":0,"bias":-0.019196726754307752,"layer":"1","squash":"LOGISTIC"},{"trace":{"elegibility":{"1430":0,"1431":0,"1432":0,"1433":0,"1434":0},"extended":{}},"state":0.26838883734308183,"old":0,"activation":0,"bias":-0.03186677508056164,"layer":"1","squash":"LOGISTIC"},{"trace":{"elegibility":{"1430":0,"1431":0,"1432":0,"1433":0,"1434":0},"extended":{}},"state":0.41579805267974734,"old":0,"activation":0,"bias":0.05471872189082205,"layer":"2","squash":"LOGISTIC"},{"trace":{"elegibility":{"1430":0,"1431":0,"1432":0,"1433":0,"1434":0},"extended":{}},"state":0.7244884569663554,"old":0,"activation":0,"bias":-0.07439912180416286,"layer":"2","squash":"LOGISTIC"},{"trace":{"elegibility":{"1430":0,"1431":0,"1432":0,"1433":0,"1434":0},"extended":{}},"state":0.033056300366297364,"old":0,"activation":0,"bias":0.09803695143200458,"layer":"2","squash":"LOGISTIC"},{"trace":{"elegibility":{"1430":0,"1431":0,"1432":0,"1433":0,"1434":0},"extended":{}},"state":0.5071320298593491,"old":0,"activation":0,"bias":0.030684541212394834,"layer":"2","squash":"LOGISTIC"},{"trace":{"elegibility":{"1430":0,"1431":0,"1432":0,"1433":0,"1434":0},"extended":{}},"state":0.010883391834795475,"old":0,"activation":0,"bias":0.0002814464736729805,"layer":"2","squash":"LOGISTIC"},{"trace":{"elegibility":{"1430":0,"1431":0,"1432":0,"1433":0,"1434":0},"extended":{}},"state":0,"old":0,"activation":0,"bias":0.04757897332310676,"layer":"output","squash":"LOGISTIC"}],"connections":[{"from":"0","to":"9","weight":0.07945252633653582,"gater":null},{"from":"0","to":"10","weight":-0.0948314699344337,"gater":null},{"from":"0","to":"11","weight":-0.05414648121222854,"gater":null},{"from":"0","to":"12","weight":0.08347687902860343,"gater":null},{"from":"0","to":"13","weight":-0.08708490389399232,"gater":null},{"from":"1","to":"9","weight":0.09672894310206176,"gater":null},{"from":"1","to":"10","weight":0.07617993638850748,"gater":null},{"from":"1","to":"11","weight":0.0074704832397401305,"gater":null},{"from":"1","to":"12","weight":0.09399466384202243,"gater":null},{"from":"1","to":"13","weight":0.0536624218337238,"gater":null},{"from":"2","to":"9","weight":-0.02577088815160096,"gater":null},{"from":"2","to":"10","weight":-0.05216443128883839,"gater":null},{"from":"2","to":"11","weight":0.05224174605682494,"gater":null},{"from":"2","to":"12","weight":-0.011080277198925612,"gater":null},{"from":"2","to":"13","weight":-0.05672206836752594,"gater":null},{"from":"3","to":"9","weight":-0.0004634045530110542,"gater":null},{"from":"3","to":"10","weight":-0.02570867477916182,"gater":null},{"from":"3","to":"11","weight":-0.04043060275726021,"gater":null},{"from":"3","to":"12","weight":-0.010079585015773773,"gater":null},{"from":"3","to":"13","weight":0.09192544245161116,"gater":null},{"from":"4","to":"9","weight":-0.04821681128814817,"gater":null},{"from":"4","to":"10","weight":0.0643792781047523,"gater":null},{"from":"4","to":"11","weight":-0.04742236924357712,"gater":null},{"from":"4","to":"12","weight":-0.011753434222191578,"gater":null},{"from":"4","to":"13","weight":0.033300832286477094,"gater":null},{"from":"5","to":"9","weight":0.00672337035648525,"gater":null},{"from":"5","to":"10","weight":0.0893687129020691,"gater":null},{"from":"5","to":"11","weight":0.025593990879133333,"gater":null},{"from":"5","to":"12","weight":0.09857849413529038,"gater":null},{"from":"5","to":"13","weight":-0.05712482901290059,"gater":null},{"from":"6","to":"9","weight":0.05521866902709008,"gater":null},{"from":"6","to":"10","weight":0.02789737712591886,"gater":null},{"from":"6","to":"11","weight":0.07993780388496816,"gater":null},{"from":"6","to":"12","weight":-0.035001447144895795,"gater":null},{"from":"6","to":"13","weight":-0.04962577195838094,"gater":null},{"from":"7","to":"9","weight":0.02383951749652624,"gater":null},{"from":"7","to":"10","weight":0.06478361953049899,"gater":null},{"from":"7","to":"11","weight":0.045140629820525635,"gater":null},{"from":"7","to":"12","weight":0.06508130510337651,"gater":null},{"from":"7","to":"13","weight":0.01843906519934535,"gater":null},{"from":"8","to":"9","weight":-0.06264062249101698,"gater":null},{"from":"8","to":"10","weight":-0.03647045721299946,"gater":null},{"from":"8","to":"11","weight":-0.0655894628725946,"gater":null},{"from":"8","to":"12","weight":0.0515630311332643,"gater":null},{"from":"8","to":"13","weight":-0.05036540795117617,"gater":null},{"from":"9","to":null,"weight":-0.09211857281625271,"gater":null},{"from":"9","to":null,"weight":-0.08194758747704328,"gater":null},{"from":"9","to":null,"weight":0.03928617653436958,"gater":null},{"from":"9","to":null,"weight":-0.09083953658118844,"gater":null},{"from":"9","to":null,"weight":0.03315310548059641,"gater":null},{"from":"9","to":null,"weight":0.07356506981886923,"gater":null},{"from":"9","to":null,"weight":-0.09307597386650741,"gater":null},{"from":"9","to":null,"weight":-0.04680815236642957,"gater":null},{"from":"9","to":null,"weight":-0.05175837022252381,"gater":null},{"from":"9","to":null,"weight":0.04915153970941902,"gater":null},{"from":"9","to":"14","weight":0.03748214659281074,"gater":null},{"from":"9","to":"15","weight":-0.026420063292607668,"gater":null},{"from":"9","to":"16","weight":-0.06486418335698546,"gater":null},{"from":"9","to":"17","weight":-0.04091248996555805,"gater":null},{"from":"9","to":"18","weight":0.06575447679497301,"gater":null},{"from":"9","to":null,"weight":-0.07381808701902629,"gater":null},{"from":"9","to":null,"weight":-0.012532856408506626,"gater":null},{"from":"9","to":null,"weight":-0.049841435393318534,"gater":null},{"from":"9","to":null,"weight":0.04292136407457292,"gater":null},{"from":"9","to":null,"weight":-0.06604660321027041,"gater":null},{"from":"9","to":null,"weight":-0.07854597973637284,"gater":null},{"from":"9","to":null,"weight":-0.06351872342638672,"gater":null},{"from":"9","to":null,"weight":0.062284811120480316,"gater":null},{"from":"9","to":null,"weight":-0.036626115348190075,"gater":null},{"from":"9","to":null,"weight":0.050710676703602076,"gater":null},{"from":"9","to":null,"weight":-0.028158514061942697,"gater":null},{"from":"9","to":null,"weight":-0.09517503171227873,"gater":null},{"from":"9","to":null,"weight":-0.02739528929814697,"gater":null},{"from":"9","to":null,"weight":-0.09082170994952321,"gater":null},{"from":"9","to":null,"weight":-0.036914734402671456,"gater":null},{"from":"9","to":null,"weight":-0.06415301500819623,"gater":null},{"from":"9","to":null,"weight":0.0809611533768475,"gater":null},{"from":"9","to":null,"weight":0.0017677409108728115,"gater":null},{"from":"9","to":null,"weight":-0.0035603479016572265,"gater":null},{"from":"9","to":null,"weight":-0.010635142959654328,"gater":null},{"from":"9","to":"14","weight":-0.06680457750335336,"gater":null},{"from":"9","to":"15","weight":-0.002456210227683192,"gater":null},{"from":"9","to":"16","weight":-0.0010917801409959793,"gater":null},{"from":"9","to":"17","weight":-0.0005226109176874189,"gater":null},{"from":"9","to":"18","weight":0.01874306700192392,"gater":null},{"from":"9","to":"9","weight":1,"gater":null},{"from":"10","to":null,"weight":-0.00839215363375842,"gater":null},{"from":"10","to":null,"weight":0.0061251206789165735,"gater":null},{"from":"10","to":null,"weight":-0.010317389061674481,"gater":null},{"from":"10","to":null,"weight":0.02978459298610686,"gater":null},{"from":"10","to":null,"weight":-0.08053780272603035,"gater":null},{"from":"10","to":null,"weight":-0.06462112795561553,"gater":null},{"from":"10","to":null,"weight":0.041339114028960455,"gater":null},{"from":"10","to":null,"weight":0.0018664920236915322,"gater":null},{"from":"10","to":null,"weight":0.002575324196368453,"gater":null},{"from":"10","to":null,"weight":-0.043129743216559296,"gater":null},{"from":"10","to":"14","weight":-0.08153887474909426,"gater":null},{"from":"10","to":"15","weight":-0.08603566084057093,"gater":null},{"from":"10","to":"16","weight":-0.026792659005150196,"gater":null},{"from":"10","to":"17","weight":-0.060787687590345744,"gater":null},{"from":"10","to":"18","weight":-0.06957658017054201,"gater":null},{"from":"10","to":null,"weight":0.08110359762795269,"gater":null},{"from":"10","to":null,"weight":-0.06145266783423722,"gater":null},{"from":"10","to":null,"weight":0.07831427948549391,"gater":null},{"from":"10","to":null,"weight":0.012647063611075288,"gater":null},{"from":"10","to":null,"weight":0.043761175544932474,"gater":null},{"from":"10","to":null,"weight":0.041165292169898754,"gater":null},{"from":"10","to":null,"weight":-0.07004279526881874,"gater":null},{"from":"10","to":null,"weight":0.0008782855700701503,"gater":null},{"from":"10","to":null,"weight":0.07102860622107984,"gater":null},{"from":"10","to":null,"weight":-0.06172120538540185,"gater":null},{"from":"10","to":null,"weight":-0.005984974699094897,"gater":null},{"from":"10","to":null,"weight":-0.0707720585167408,"gater":null},{"from":"10","to":null,"weight":-0.028514713793992993,"gater":null},{"from":"10","to":null,"weight":-0.019388325046747923,"gater":null},{"from":"10","to":null,"weight":-0.07094855792820454,"gater":null},{"from":"10","to":null,"weight":0.09725492568686606,"gater":null},{"from":"10","to":null,"weight":-0.08308278121985496,"gater":null},{"from":"10","to":null,"weight":0.003357124095782635,"gater":null},{"from":"10","to":null,"weight":0.032030114671215415,"gater":null},{"from":"10","to":null,"weight":0.054618228645995276,"gater":null},{"from":"10","to":"14","weight":-0.0068681929726153584,"gater":null},{"from":"10","to":"15","weight":0.028727787872776384,"gater":null},{"from":"10","to":"16","weight":0.039758883742615575,"gater":null},{"from":"10","to":"17","weight":0.08596999594010413,"gater":null},{"from":"10","to":"18","weight":-0.03137854128144682,"gater":null},{"from":"10","to":"10","weight":1,"gater":null},{"from":"11","to":null,"weight":0.03660767902620138,"gater":null},{"from":"11","to":null,"weight":0.06444397736340762,"gater":null},{"from":"11","to":null,"weight":0.077570561459288,"gater":null},{"from":"11","to":null,"weight":0.06902833464555444,"gater":null},{"from":"11","to":null,"weight":0.061619577230885625,"gater":null},{"from":"11","to":null,"weight":-0.042482079658657315,"gater":null},{"from":"11","to":null,"weight":0.08325799279846252,"gater":null},{"from":"11","to":null,"weight":0.07321359938941896,"gater":null},{"from":"11","to":null,"weight":0.0003562463447451536,"gater":null},{"from":"11","to":null,"weight":-0.09451061743311584,"gater":null},{"from":"11","to":"14","weight":-0.06765838270075619,"gater":null},{"from":"11","to":"15","weight":0.06170521392486991,"gater":null},{"from":"11","to":"16","weight":0.013568006549030537,"gater":null},{"from":"11","to":"17","weight":0.0661378873512149,"gater":null},{"from":"11","to":"18","weight":-0.03998519480228424,"gater":null},{"from":"11","to":null,"weight":-0.06666686125099659,"gater":null},{"from":"11","to":null,"weight":-0.01102807763963938,"gater":null},{"from":"11","to":null,"weight":0.07206649347208441,"gater":null},{"from":"11","to":null,"weight":0.00651268833316862,"gater":null},{"from":"11","to":null,"weight":0.01059452081099152,"gater":null},{"from":"11","to":null,"weight":-0.06450205598957837,"gater":null},{"from":"11","to":null,"weight":0.08284390438348055,"gater":null},{"from":"11","to":null,"weight":-0.08904487667605282,"gater":null},{"from":"11","to":null,"weight":0.09557014801539482,"gater":null},{"from":"11","to":null,"weight":0.0850238013546914,"gater":null},{"from":"11","to":null,"weight":-0.09449351276271045,"gater":null},{"from":"11","to":null,"weight":0.024102808069437737,"gater":null},{"from":"11","to":null,"weight":0.048050594842061395,"gater":null},{"from":"11","to":null,"weight":0.011505006486549979,"gater":null},{"from":"11","to":null,"weight":0.06293728994205594,"gater":null},{"from":"11","to":null,"weight":0.011320946644991642,"gater":null},{"from":"11","to":null,"weight":-0.03929686108604074,"gater":null},{"from":"11","to":null,"weight":0.07021388886496424,"gater":null},{"from":"11","to":null,"weight":-0.06451908499002457,"gater":null},{"from":"11","to":null,"weight":0.05956970448605717,"gater":null},{"from":"11","to":"14","weight":-0.0363948229700327,"gater":null},{"from":"11","to":"15","weight":0.0069531528744846555,"gater":null},{"from":"11","to":"16","weight":0.052298816200345766,"gater":null},{"from":"11","to":"17","weight":-0.018709937855601308,"gater":null},{"from":"11","to":"18","weight":0.07560211154632271,"gater":null},{"from":"11","to":"11","weight":1,"gater":null},{"from":"12","to":null,"weight":0.015725805843248966,"gater":null},{"from":"12","to":null,"weight":0.059105900349095464,"gater":null},{"from":"12","to":null,"weight":0.0228212901391089,"gater":null},{"from":"12","to":null,"weight":-0.04185716751962901,"gater":null},{"from":"12","to":null,"weight":0.01707159378565848,"gater":null},{"from":"12","to":null,"weight":0.011811860278248792,"gater":null},{"from":"12","to":null,"weight":-0.04215735574252904,"gater":null},{"from":"12","to":null,"weight":0.09329220508225264,"gater":null},{"from":"12","to":null,"weight":-0.041832551732659345,"gater":null},{"from":"12","to":null,"weight":0.013131104689091441,"gater":null},{"from":"12","to":"14","weight":-0.08463451811112464,"gater":null},{"from":"12","to":"15","weight":-0.0609944764059037,"gater":null},{"from":"12","to":"16","weight":0.09441213863901796,"gater":null},{"from":"12","to":"17","weight":0.06040332810953261,"gater":null},{"from":"12","to":"18","weight":-0.027332433592528113,"gater":null},{"from":"12","to":null,"weight":0.08010074687190355,"gater":null},{"from":"12","to":null,"weight":0.06906016925349831,"gater":null},{"from":"12","to":null,"weight":-0.04061043029651046,"gater":null},{"from":"12","to":null,"weight":-0.0319487763568759,"gater":null},{"from":"12","to":null,"weight":-0.016051834682002664,"gater":null},{"from":"12","to":null,"weight":-0.04231657176278532,"gater":null},{"from":"12","to":null,"weight":0.05575563297607006,"gater":null},{"from":"12","to":null,"weight":-0.03702022680081428,"gater":null},{"from":"12","to":null,"weight":0.08794466974213719,"gater":null},{"from":"12","to":null,"weight":-0.0845180643722415,"gater":null},{"from":"12","to":null,"weight":0.034305442636832606,"gater":null},{"from":"12","to":null,"weight":-0.05853993748314679,"gater":null},{"from":"12","to":null,"weight":-0.07937563927844167,"gater":null},{"from":"12","to":null,"weight":0.0722949094604701,"gater":null},{"from":"12","to":null,"weight":-0.030187100498005756,"gater":null},{"from":"12","to":null,"weight":0.020927385846152904,"gater":null},{"from":"12","to":null,"weight":-0.09953224919736386,"gater":null},{"from":"12","to":null,"weight":-0.05973652256652713,"gater":null},{"from":"12","to":null,"weight":0.051403649011626834,"gater":null},{"from":"12","to":null,"weight":-0.0460945637896657,"gater":null},{"from":"12","to":"14","weight":0.007862521940842276,"gater":null},{"from":"12","to":"15","weight":-0.024049204774200916,"gater":null},{"from":"12","to":"16","weight":0.08398072067648174,"gater":null},{"from":"12","to":"17","weight":-0.09145373282954097,"gater":null},{"from":"12","to":"18","weight":0.009015144174918527,"gater":null},{"from":"12","to":"12","weight":1,"gater":null},{"from":"13","to":null,"weight":0.08310752939432861,"gater":null},{"from":"13","to":null,"weight":-0.042653166037052874,"gater":null},{"from":"13","to":null,"weight":0.03745447359979154,"gater":null},{"from":"13","to":null,"weight":-0.09209994194097817,"gater":null},{"from":"13","to":null,"weight":0.02967475387267768,"gater":null},{"from":"13","to":null,"weight":0.09079355150461196,"gater":null},{"from":"13","to":null,"weight":0.027708288514986634,"gater":null},{"from":"13","to":null,"weight":0.0463811730965972,"gater":null},{"from":"13","to":null,"weight":0.0394700865726918,"gater":null},{"from":"13","to":null,"weight":-0.06734842439182104,"gater":null},{"from":"13","to":"14","weight":-0.04367787539958954,"gater":null},{"from":"13","to":"15","weight":0.00910094399005175,"gater":null},{"from":"13","to":"16","weight":-0.035563092678785324,"gater":null},{"from":"13","to":"17","weight":-0.09738875911571086,"gater":null},{"from":"13","to":"18","weight":-0.058921897225081926,"gater":null},{"from":"13","to":null,"weight":0.07899202504195274,"gater":null},{"from":"13","to":null,"weight":-0.06462929681874813,"gater":null},{"from":"13","to":null,"weight":0.035719579225406056,"gater":null},{"from":"13","to":null,"weight":0.08315072809346022,"gater":null},{"from":"13","to":null,"weight":0.0129630015231669,"gater":null},{"from":"13","to":null,"weight":-0.0644368892069906,"gater":null},{"from":"13","to":null,"weight":-0.05004383306950331,"gater":null},{"from":"13","to":null,"weight":0.05374582973308861,"gater":null},{"from":"13","to":null,"weight":-0.043933627754449846,"gater":null},{"from":"13","to":null,"weight":-0.06647135745733976,"gater":null},{"from":"13","to":null,"weight":0.07534806234762073,"gater":null},{"from":"13","to":null,"weight":-0.06564373336732388,"gater":null},{"from":"13","to":null,"weight":0.051096817851066595,"gater":null},{"from":"13","to":null,"weight":-0.038153718085959555,"gater":null},{"from":"13","to":null,"weight":-0.0020863947458565207,"gater":null},{"from":"13","to":null,"weight":-0.032225360115990045,"gater":null},{"from":"13","to":null,"weight":-0.07823075596243144,"gater":null},{"from":"13","to":null,"weight":0.07989547508768738,"gater":null},{"from":"13","to":null,"weight":-0.017407718766480687,"gater":null},{"from":"13","to":null,"weight":0.06696489346213638,"gater":null},{"from":"13","to":"14","weight":0.07816910301335156,"gater":null},{"from":"13","to":"15","weight":0.08587404782883823,"gater":null},{"from":"13","to":"16","weight":-0.005147025967016813,"gater":null},{"from":"13","to":"17","weight":-0.012746573938056824,"gater":null},{"from":"13","to":"18","weight":0.09364681481383741,"gater":null},{"from":"13","to":"13","weight":1,"gater":null},{"from":"14","to":null,"weight":-0.038284973148256546,"gater":null},{"from":"14","to":null,"weight":0.06941559724509716,"gater":null},{"from":"14","to":null,"weight":0.022970800707116726,"gater":null},{"from":"14","to":null,"weight":0.032908410625532264,"gater":null},{"from":"14","to":null,"weight":0.06457270346581936,"gater":null},{"from":"14","to":null,"weight":-0.09151577223092318,"gater":null},{"from":"14","to":null,"weight":0.03993411236442626,"gater":null},{"from":"14","to":null,"weight":0.08680676962248982,"gater":null},{"from":"14","to":null,"weight":-0.0911962009035051,"gater":null},{"from":"14","to":null,"weight":-0.0035455008503049584,"gater":null},{"from":"14","to":null,"weight":0.06134793101809918,"gater":null},{"from":"14","to":null,"weight":-0.0723502307664603,"gater":null},{"from":"14","to":null,"weight":-0.08195843785069884,"gater":null},{"from":"14","to":null,"weight":-0.024905965058133,"gater":null},{"from":"14","to":null,"weight":-0.010959540214389565,"gater":null},{"from":"14","to":null,"weight":-0.06492050508968533,"gater":null},{"from":"14","to":null,"weight":0.08065720782615246,"gater":null},{"from":"14","to":null,"weight":0.08085191552527249,"gater":null},{"from":"14","to":null,"weight":0.06732770707458258,"gater":null},{"from":"14","to":null,"weight":-0.04026539870537818,"gater":null},{"from":"14","to":"9","weight":-0.07463030903600157,"gater":null},{"from":"14","to":"10","weight":0.09207491483539343,"gater":null},{"from":"14","to":"11","weight":0.010498260427266357,"gater":null},{"from":"14","to":"12","weight":0.0031392656266689273,"gater":null},{"from":"14","to":"13","weight":0.06182144279591739,"gater":null},{"from":"14","to":"19","weight":0.04420044883154334,"gater":null},{"from":"14","to":"20","weight":0.013936637621372941,"gater":null},{"from":"14","to":"21","weight":0.02273700498044491,"gater":null},{"from":"14","to":"22","weight":-0.07645594663918019,"gater":null},{"from":"14","to":"23","weight":0.07578479032963514,"gater":null},{"from":"15","to":null,"weight":-0.027985794283449647,"gater":null},{"from":"15","to":null,"weight":-0.09252681857906282,"gater":null},{"from":"15","to":null,"weight":0.004364460986107585,"gater":null},{"from":"15","to":null,"weight":0.06447235257364811,"gater":null},{"from":"15","to":null,"weight":0.0959406671114266,"gater":null},{"from":"15","to":null,"weight":0.014383934205397964,"gater":null},{"from":"15","to":null,"weight":0.006843511993065474,"gater":null},{"from":"15","to":null,"weight":-0.057430269336327916,"gater":null},{"from":"15","to":null,"weight":0.09498634180054069,"gater":null},{"from":"15","to":null,"weight":-0.07359015746042133,"gater":null},{"from":"15","to":null,"weight":-0.0615872610360384,"gater":null},{"from":"15","to":null,"weight":-0.01976928506046534,"gater":null},{"from":"15","to":null,"weight":0.0189378120470792,"gater":null},{"from":"15","to":null,"weight":-0.043281792057678105,"gater":null},{"from":"15","to":null,"weight":-0.06798038915731014,"gater":null},{"from":"15","to":null,"weight":-0.08919637333601714,"gater":null},{"from":"15","to":null,"weight":0.04029644452966749,"gater":null},{"from":"15","to":null,"weight":0.0071017982903867904,"gater":null},{"from":"15","to":null,"weight":0.03403917667455972,"gater":null},{"from":"15","to":null,"weight":-0.023240417288616297,"gater":null},{"from":"15","to":"9","weight":-0.005807930184528229,"gater":null},{"from":"15","to":"10","weight":0.023818750679492948,"gater":null},{"from":"15","to":"11","weight":-0.07152006216347218,"gater":null},{"from":"15","to":"12","weight":-0.06380958636291326,"gater":null},{"from":"15","to":"13","weight":-0.08917096592485906,"gater":null},{"from":"15","to":"19","weight":-0.0484105640091002,"gater":null},{"from":"15","to":"20","weight":-0.020590253314003354,"gater":null},{"from":"15","to":"21","weight":0.08248630966991186,"gater":null},{"from":"15","to":"22","weight":-0.08493951079435647,"gater":null},{"from":"15","to":"23","weight":-0.09180102334357798,"gater":null},{"from":"16","to":null,"weight":0.019596473313868046,"gater":null},{"from":"16","to":null,"weight":-0.035539788752794274,"gater":null},{"from":"16","to":null,"weight":0.0771313883829862,"gater":null},{"from":"16","to":null,"weight":-0.08656691168434918,"gater":null},{"from":"16","to":null,"weight":0.08650257121771573,"gater":null},{"from":"16","to":null,"weight":0.07299024229869247,"gater":null},{"from":"16","to":null,"weight":0.09974171998910605,"gater":null},{"from":"16","to":null,"weight":0.06305765947327019,"gater":null},{"from":"16","to":null,"weight":-0.03596879336982965,"gater":null},{"from":"16","to":null,"weight":-0.015412226086482406,"gater":null},{"from":"16","to":null,"weight":0.03249653396196664,"gater":null},{"from":"16","to":null,"weight":-0.005383799271658066,"gater":null},{"from":"16","to":null,"weight":-0.07969159819185734,"gater":null},{"from":"16","to":null,"weight":0.0039292750414460925,"gater":null},{"from":"16","to":null,"weight":0.07492757248692214,"gater":null},{"from":"16","to":null,"weight":0.06894443086348476,"gater":null},{"from":"16","to":null,"weight":-0.04425418167375028,"gater":null},{"from":"16","to":null,"weight":0.06852601696737112,"gater":null},{"from":"16","to":null,"weight":-0.08987986096180976,"gater":null},{"from":"16","to":null,"weight":0.06779723712243141,"gater":null},{"from":"16","to":"9","weight":0.05196555005386472,"gater":null},{"from":"16","to":"10","weight":0.015533858258277175,"gater":null},{"from":"16","to":"11","weight":0.0735269350465387,"gater":null},{"from":"16","to":"12","weight":-0.04687410742044449,"gater":null},{"from":"16","to":"13","weight":-0.04607851537875832,"gater":null},{"from":"16","to":"19","weight":0.088375762430951,"gater":null},{"from":"16","to":"20","weight":0.08851587339304387,"gater":null},{"from":"16","to":"21","weight":-0.007597256777808065,"gater":null},{"from":"16","to":"22","weight":0.022818393027409914,"gater":null},{"from":"16","to":"23","weight":-0.06045390996150673,"gater":null},{"from":"17","to":null,"weight":-0.04717757916077972,"gater":null},{"from":"17","to":null,"weight":0.0695411075372249,"gater":null},{"from":"17","to":null,"weight":-0.04650129750370979,"gater":null},{"from":"17","to":null,"weight":-0.09964733747765422,"gater":null},{"from":"17","to":null,"weight":-0.03942648502998054,"gater":null},{"from":"17","to":null,"weight":0.030299098510295164,"gater":null},{"from":"17","to":null,"weight":-0.011058242386206979,"gater":null},{"from":"17","to":null,"weight":0.08568371925503016,"gater":null},{"from":"17","to":null,"weight":-0.08743681441992522,"gater":null},{"from":"17","to":null,"weight":0.05651157475076615,"gater":null},{"from":"17","to":null,"weight":0.0483338160905987,"gater":null},{"from":"17","to":null,"weight":0.011800705175846818,"gater":null},{"from":"17","to":null,"weight":0.03037443440407514,"gater":null},{"from":"17","to":null,"weight":0.08823318220674992,"gater":null},{"from":"17","to":null,"weight":0.004046285245567563,"gater":null},{"from":"17","to":null,"weight":-0.030380434589460492,"gater":null},{"from":"17","to":null,"weight":-0.00638546040281654,"gater":null},{"from":"17","to":null,"weight":-0.00201049805618822,"gater":null},{"from":"17","to":null,"weight":0.01800580313429237,"gater":null},{"from":"17","to":null,"weight":0.00005381722003221234,"gater":null},{"from":"17","to":"9","weight":-0.08321641250513495,"gater":null},{"from":"17","to":"10","weight":0.0679185665678233,"gater":null},{"from":"17","to":"11","weight":-0.07246509217657149,"gater":null},{"from":"17","to":"12","weight":-0.08282693005166948,"gater":null},{"from":"17","to":"13","weight":-0.0015455762390047256,"gater":null},{"from":"17","to":"19","weight":0.008675749925896523,"gater":null},{"from":"17","to":"20","weight":0.09692346123047174,"gater":null},{"from":"17","to":"21","weight":-0.03970172554254532,"gater":null},{"from":"17","to":"22","weight":-0.020224385056644673,"gater":null},{"from":"17","to":"23","weight":0.07427021712064744,"gater":null},{"from":"18","to":null,"weight":0.027444681059569126,"gater":null},{"from":"18","to":null,"weight":0.05612432807683945,"gater":null},{"from":"18","to":null,"weight":0.06025132695212962,"gater":null},{"from":"18","to":null,"weight":0.0016345004551112652,"gater":null},{"from":"18","to":null,"weight":0.053370299749076366,"gater":null},{"from":"18","to":null,"weight":0.035822514398023475,"gater":null},{"from":"18","to":null,"weight":-0.0707115478347987,"gater":null},{"from":"18","to":null,"weight":-0.08280265349894762,"gater":null},{"from":"18","to":null,"weight":0.08688558363355697,"gater":null},{"from":"18","to":null,"weight":0.022048446629196403,"gater":null},{"from":"18","to":null,"weight":-0.028897048206999898,"gater":null},{"from":"18","to":null,"weight":0.002996845217421648,"gater":null},{"from":"18","to":null,"weight":0.057773518003523344,"gater":null},{"from":"18","to":null,"weight":0.06400816780515015,"gater":null},{"from":"18","to":null,"weight":0.06729341428726912,"gater":null},{"from":"18","to":null,"weight":0.06696968898177147,"gater":null},{"from":"18","to":null,"weight":0.026678082440048462,"gater":null},{"from":"18","to":null,"weight":0.005178514914587137,"gater":null},{"from":"18","to":null,"weight":0.08449807451106608,"gater":null},{"from":"18","to":null,"weight":0.07123754471540453,"gater":null},{"from":"18","to":"9","weight":0.04023356735706329,"gater":null},{"from":"18","to":"10","weight":-0.0789310344029218,"gater":null},{"from":"18","to":"11","weight":0.05543465628288688,"gater":null},{"from":"18","to":"12","weight":0.055639316001907,"gater":null},{"from":"18","to":"13","weight":0.0851138054393232,"gater":null},{"from":"18","to":"19","weight":0.09399297484196723,"gater":null},{"from":"18","to":"20","weight":-0.058004944166168575,"gater":null},{"from":"18","to":"21","weight":0.007633945252746341,"gater":null},{"from":"18","to":"22","weight":0.03999693933874368,"gater":null},{"from":"18","to":"23","weight":-0.012078848900273442,"gater":null},{"from":"19","to":"24","weight":-0.09521303749643267,"gater":null},{"from":"20","to":"24","weight":-0.03149339966475964,"gater":null},{"from":"21","to":"24","weight":0.07767248130403459,"gater":null},{"from":"22","to":"24","weight":0.012804187694564456,"gater":null},{"from":"23","to":"24","weight":0.02699042172171176,"gater":null}]}

from synaptic.

cazala avatar cazala commented on August 20, 2024

Well, the error that you are getting ('Invalid neurons') comes from the Connection object, because one or both of the two neurons that you are trying to connect are not a Neuron, ie:

var A = new Neuron();
A.project(null) // throws 'Invalid neurons'

And in that json that you pasted I can see many connections that say "to":null, that's what's causing the error. Does the json look like that just after you call toJSON() or is it after you store it and fetch it back from Mongo? Also, could you share the architecture you are using? Maybe that will shed some light on the issue.

from synaptic.

Leekao avatar Leekao commented on August 20, 2024

Yeah, I noticed these nulls too and thought that had smthing to do with it, I'll try to get the console.log of the JSON before saving it to disk, I really don't know what to tell you about the architecture, it's just a nodejs running on ubuntu, I use coffeescript (maybe that has smthing to do with it?) and mongodb 2.6.

from synaptic.

cazala avatar cazala commented on August 20, 2024

Sorry, by architecture I meant the neural network topology (the way you are connecting the neurons), you said that you are creating random networks, I believe the problem is the way you are connecting the neurons (maybe there are corner cases wheretoJSON doesn't work, because I haven't tested it on every possible scenario)

from synaptic.

Leekao avatar Leekao commented on August 20, 2024

this is the code:

create_layer = ->
    layer =  new Synaptic.Layer(5)
    for n in layer.list
        n.state = Math.random()
    return layer

create_brain = (hiddenLayer1 = create_layer(), hiddenLayer2=create_layer()) ->
    inputLayer = new Synaptic.Layer(9)
    outputLayer = new Synaptic.Layer(1)
    hiddenLayer3 = create_layer()
    inputLayer.project(hiddenLayer1)
    hiddenLayer1.project(hiddenLayer2)
    hiddenLayer2.project(hiddenLayer3)
    hiddenLayer3.project(outputLayer)
    return new Synaptic.Network
        input: inputLayer
        hidden: [hiddenLayer1, hiddenLayer2, hiddenLayer3]
        output: outputLayer

consumate = (father, mother) ->
    random_factor = Math.round Math.random()
    if random_factor is 0
        father_genes = father.brain.layers.hidden[0]
        mother_genes = mother.brain.layers.hidden[1]
    else
        father_genes = father.brain.layers.hidden[1]
        mother_genes = mother.brain.layers.hidden[0]
    return create_brain(father_genes, mother_genes)

from synaptic.

cazala avatar cazala commented on August 20, 2024

I converted that coffeescript to this javascript:

var create_brain, create_layer;

create_layer = function() {
  var layer, n, _i, _len, _ref;
  layer = new synaptic.Layer(5);
  _ref = layer.list;
  for (_i = 0, _len = _ref.length; _i < _len; _i++) {
    n = _ref[_i];
    n.state = Math.random();
  }
  return layer;
};

create_brain = function(hiddenLayer1, hiddenLayer2) {
  var hiddenLayer3, inputLayer, outputLayer;
  if (hiddenLayer1 == null) {
    hiddenLayer1 = create_layer();
  }
  if (hiddenLayer2 == null) {
    hiddenLayer2 = create_layer();
  }
  inputLayer = new synaptic.Layer(9);
  outputLayer = new synaptic.Layer(1);
  hiddenLayer3 = create_layer();
  inputLayer.project(hiddenLayer1);
  hiddenLayer1.project(hiddenLayer2);
  hiddenLayer2.project(hiddenLayer3);
  hiddenLayer3.project(outputLayer);
  return new synaptic.Network({
    input: inputLayer,
    hidden: [hiddenLayer1, hiddenLayer2, hiddenLayer3],
    output: outputLayer
  });
};

And when I run: console.log( JSON.stringify( create_brain().toJSON() ) )

I get this:

{"neurons":[{"trace":{"elegibility":{"11675":0,"11676":0,"11677":0,"11678":0,"11679":0},"extended":{}},"state":0,"old":0,"activation":0,"bias":-0.027814825996756554,"layer":"input","squash":"LOGISTIC"},{"trace":{"elegibility":{"11675":0,"11676":0,"11677":0,"11678":0,"11679":0},"extended":{}},"state":0,"old":0,"activation":0,"bias":0.0004076424986124011,"layer":"input","squash":"LOGISTIC"},{"trace":{"elegibility":{"11675":0,"11676":0,"11677":0,"11678":0,"11679":0},"extended":{}},"state":0,"old":0,"activation":0,"bias":0.03794363602064549,"layer":"input","squash":"LOGISTIC"},{"trace":{"elegibility":{"11675":0,"11676":0,"11677":0,"11678":0,"11679":0},"extended":{}},"state":0,"old":0,"activation":0,"bias":0.030987338162958622,"layer":"input","squash":"LOGISTIC"},{"trace":{"elegibility":{"11675":0,"11676":0,"11677":0,"11678":0,"11679":0},"extended":{}},"state":0,"old":0,"activation":0,"bias":-0.011568570416420704,"layer":"input","squash":"LOGISTIC"},{"trace":{"elegibility":{"11675":0,"11676":0,"11677":0,"11678":0,"11679":0},"extended":{}},"state":0,"old":0,"activation":0,"bias":-0.05688998722471297,"layer":"input","squash":"LOGISTIC"},{"trace":{"elegibility":{"11675":0,"11676":0,"11677":0,"11678":0,"11679":0},"extended":{}},"state":0,"old":0,"activation":0,"bias":-0.01804000856354833,"layer":"input","squash":"LOGISTIC"},{"trace":{"elegibility":{"11675":0,"11676":0,"11677":0,"11678":0,"11679":0},"extended":{}},"state":0,"old":0,"activation":0,"bias":0.014742393093183634,"layer":"input","squash":"LOGISTIC"},{"trace":{"elegibility":{"11675":0,"11676":0,"11677":0,"11678":0,"11679":0},"extended":{}},"state":0,"old":0,"activation":0,"bias":0.08457215232774615,"layer":"input","squash":"LOGISTIC"},{"trace":{"elegibility":{"11675":0,"11676":0,"11677":0,"11678":0,"11679":0},"extended":{}},"state":0.09302823524922132,"old":0,"activation":0,"bias":0.09523127088323236,"layer":"0","squash":"LOGISTIC"},{"trace":{"elegibility":{"11675":0,"11676":0,"11677":0,"11678":0,"11679":0},"extended":{}},"state":0.3721525785513222,"old":0,"activation":0,"bias":-0.08775776410475374,"layer":"0","squash":"LOGISTIC"},{"trace":{"elegibility":{"11675":0,"11676":0,"11677":0,"11678":0,"11679":0},"extended":{}},"state":0.8289125780574977,"old":0,"activation":0,"bias":0.05174058857373895,"layer":"0","squash":"LOGISTIC"},{"trace":{"elegibility":{"11675":0,"11676":0,"11677":0,"11678":0,"11679":0},"extended":{}},"state":0.2270453020464629,"old":0,"activation":0,"bias":-0.03341178442351521,"layer":"0","squash":"LOGISTIC"},{"trace":{"elegibility":{"11675":0,"11676":0,"11677":0,"11678":0,"11679":0},"extended":{}},"state":0.6785176135599613,"old":0,"activation":0,"bias":0.09280256275087595,"layer":"0","squash":"LOGISTIC"},{"trace":{"elegibility":{"11675":0,"11676":0,"11677":0,"11678":0,"11679":0},"extended":{}},"state":0.971201416105032,"old":0,"activation":0,"bias":0.028830094542354356,"layer":"1","squash":"LOGISTIC"},{"trace":{"elegibility":{"11675":0,"11676":0,"11677":0,"11678":0,"11679":0},"extended":{}},"state":0.6950254498515278,"old":0,"activation":0,"bias":-0.05855765929445625,"layer":"1","squash":"LOGISTIC"},{"trace":{"elegibility":{"11675":0,"11676":0,"11677":0,"11678":0,"11679":0},"extended":{}},"state":0.5243554704356939,"old":0,"activation":0,"bias":0.09538849438540639,"layer":"1","squash":"LOGISTIC"},{"trace":{"elegibility":{"11675":0,"11676":0,"11677":0,"11678":0,"11679":0},"extended":{}},"state":0.27629440440796316,"old":0,"activation":0,"bias":-0.08366822274401785,"layer":"1","squash":"LOGISTIC"},{"trace":{"elegibility":{"11675":0,"11676":0,"11677":0,"11678":0,"11679":0},"extended":{}},"state":0.6690702359192073,"old":0,"activation":0,"bias":-0.017137009557336574,"layer":"1","squash":"LOGISTIC"},{"trace":{"elegibility":{"11675":0,"11676":0,"11677":0,"11678":0,"11679":0},"extended":{}},"state":0.7474695688579232,"old":0,"activation":0,"bias":-0.04354959009215236,"layer":"2","squash":"LOGISTIC"},{"trace":{"elegibility":{"11675":0,"11676":0,"11677":0,"11678":0,"11679":0},"extended":{}},"state":0.06914554792456329,"old":0,"activation":0,"bias":0.07344383760355414,"layer":"2","squash":"LOGISTIC"},{"trace":{"elegibility":{"11675":0,"11676":0,"11677":0,"11678":0,"11679":0},"extended":{}},"state":0.7560906519647688,"old":0,"activation":0,"bias":-0.09630090408027173,"layer":"2","squash":"LOGISTIC"},{"trace":{"elegibility":{"11675":0,"11676":0,"11677":0,"11678":0,"11679":0},"extended":{}},"state":0.29028646647930145,"old":0,"activation":0,"bias":0.03582799416035415,"layer":"2","squash":"LOGISTIC"},{"trace":{"elegibility":{"11675":0,"11676":0,"11677":0,"11678":0,"11679":0},"extended":{}},"state":0.01416846620850265,"old":0,"activation":0,"bias":0.07330662789754569,"layer":"2","squash":"LOGISTIC"},{"trace":{"elegibility":{"11675":0,"11676":0,"11677":0,"11678":0,"11679":0},"extended":{}},"state":0,"old":0,"activation":0,"bias":-0.06570092467591167,"layer":"output","squash":"LOGISTIC"}],"connections":[{"from":"0","to":"9","weight":-0.02250216281972825,"gater":null},{"from":"0","to":"10","weight":-0.04024748271331191,"gater":null},{"from":"0","to":"11","weight":0.02042362336069345,"gater":null},{"from":"0","to":"12","weight":-0.06835326412692666,"gater":null},{"from":"0","to":"13","weight":-0.07635387857444585,"gater":null},{"from":"1","to":"9","weight":0.028409884870052332,"gater":null},{"from":"1","to":"10","weight":-0.08258951883763076,"gater":null},{"from":"1","to":"11","weight":0.0426465671043843,"gater":null},{"from":"1","to":"12","weight":-0.0011052813380956622,"gater":null},{"from":"1","to":"13","weight":-0.03417361727915705,"gater":null},{"from":"2","to":"9","weight":-0.07753561311401427,"gater":null},{"from":"2","to":"10","weight":-0.05616324949078262,"gater":null},{"from":"2","to":"11","weight":0.05933199683204293,"gater":null},{"from":"2","to":"12","weight":0.01796197914518416,"gater":null},{"from":"2","to":"13","weight":-0.04467357066459954,"gater":null},{"from":"3","to":"9","weight":0.04792674724012613,"gater":null},{"from":"3","to":"10","weight":-0.0005514777265489129,"gater":null},{"from":"3","to":"11","weight":-0.01850243890658021,"gater":null},{"from":"3","to":"12","weight":-0.07826011474244297,"gater":null},{"from":"3","to":"13","weight":0.05263006216846408,"gater":null},{"from":"4","to":"9","weight":-0.019050391251221294,"gater":null},{"from":"4","to":"10","weight":0.032193810492753994,"gater":null},{"from":"4","to":"11","weight":-0.038063227431848645,"gater":null},{"from":"4","to":"12","weight":0.03207995686680079,"gater":null},{"from":"4","to":"13","weight":0.06582436235621572,"gater":null},{"from":"5","to":"9","weight":-0.06840665386989714,"gater":null},{"from":"5","to":"10","weight":-0.054278980148956185,"gater":null},{"from":"5","to":"11","weight":0.011152790114283564,"gater":null},{"from":"5","to":"12","weight":-0.032674117898568514,"gater":null},{"from":"5","to":"13","weight":-0.002751615643501279,"gater":null},{"from":"6","to":"9","weight":0.08760072682052852,"gater":null},{"from":"6","to":"10","weight":-0.032482620095834136,"gater":null},{"from":"6","to":"11","weight":0.08474363987334074,"gater":null},{"from":"6","to":"12","weight":0.0026067719794809763,"gater":null},{"from":"6","to":"13","weight":-0.05936824521049858,"gater":null},{"from":"7","to":"9","weight":-0.09297290495596827,"gater":null},{"from":"7","to":"10","weight":-0.025427319947630173,"gater":null},{"from":"7","to":"11","weight":-0.0063363826833665315,"gater":null},{"from":"7","to":"12","weight":0.03734301235526799,"gater":null},{"from":"7","to":"13","weight":-0.010437738476321096,"gater":null},{"from":"8","to":"9","weight":-0.09655953273177148,"gater":null},{"from":"8","to":"10","weight":-0.06421959600411356,"gater":null},{"from":"8","to":"11","weight":-0.007132218731567261,"gater":null},{"from":"8","to":"12","weight":0.0656185511033982,"gater":null},{"from":"8","to":"13","weight":-0.020771575672551987,"gater":null},{"from":"9","to":"14","weight":0.002688359189778569,"gater":null},{"from":"9","to":"15","weight":-0.05779202817939222,"gater":null},{"from":"9","to":"16","weight":0.09901487422175706,"gater":null},{"from":"9","to":"17","weight":-0.060880034090951086,"gater":null},{"from":"9","to":"18","weight":0.04204480582848191,"gater":null},{"from":"10","to":"14","weight":-0.034704587701708076,"gater":null},{"from":"10","to":"15","weight":0.015323136001825333,"gater":null},{"from":"10","to":"16","weight":-0.010580606292933226,"gater":null},{"from":"10","to":"17","weight":-0.08870818880386651,"gater":null},{"from":"10","to":"18","weight":-0.0895842150785029,"gater":null},{"from":"11","to":"14","weight":0.0972674381453544,"gater":null},{"from":"11","to":"15","weight":0.002082737255841488,"gater":null},{"from":"11","to":"16","weight":0.08008865742012858,"gater":null},{"from":"11","to":"17","weight":-0.09825432267971337,"gater":null},{"from":"11","to":"18","weight":0.02281391667202115,"gater":null},{"from":"12","to":"14","weight":-0.0011493504047393743,"gater":null},{"from":"12","to":"15","weight":-0.009956772113218909,"gater":null},{"from":"12","to":"16","weight":-0.013483525672927502,"gater":null},{"from":"12","to":"17","weight":-0.022719373693689704,"gater":null},{"from":"12","to":"18","weight":0.07612871900200843,"gater":null},{"from":"13","to":"14","weight":0.07481791842728855,"gater":null},{"from":"13","to":"15","weight":0.09706409587524831,"gater":null},{"from":"13","to":"16","weight":-0.0392395474947989,"gater":null},{"from":"13","to":"17","weight":0.010973667167127138,"gater":null},{"from":"13","to":"18","weight":-0.07490329681895674,"gater":null},{"from":"14","to":"19","weight":-0.013751217583194378,"gater":null},{"from":"14","to":"20","weight":-0.027605643356218942,"gater":null},{"from":"14","to":"21","weight":-0.016078550694510335,"gater":null},{"from":"14","to":"22","weight":0.00271032406017184,"gater":null},{"from":"14","to":"23","weight":-0.01631749453954398,"gater":null},{"from":"15","to":"19","weight":-0.080755964666605,"gater":null},{"from":"15","to":"20","weight":0.04425666602328421,"gater":null},{"from":"15","to":"21","weight":0.05164391594007611,"gater":null},{"from":"15","to":"22","weight":0.04216573522426187,"gater":null},{"from":"15","to":"23","weight":-0.05784043096937239,"gater":null},{"from":"16","to":"19","weight":0.029506448656320572,"gater":null},{"from":"16","to":"20","weight":0.07583054555580021,"gater":null},{"from":"16","to":"21","weight":-0.04806263027712703,"gater":null},{"from":"16","to":"22","weight":-0.0669200774282217,"gater":null},{"from":"16","to":"23","weight":-0.0893187857232988,"gater":null},{"from":"17","to":"19","weight":0.09027896341867744,"gater":null},{"from":"17","to":"20","weight":-0.0009576388169079963,"gater":null},{"from":"17","to":"21","weight":0.07506676581688226,"gater":null},{"from":"17","to":"22","weight":-0.06726578604429961,"gater":null},{"from":"17","to":"23","weight":-0.07306456230580807,"gater":null},{"from":"18","to":"19","weight":-0.0562892475631088,"gater":null},{"from":"18","to":"20","weight":0.00460833846591413,"gater":null},{"from":"18","to":"21","weight":-0.0029537881258875076,"gater":null},{"from":"18","to":"22","weight":0.06632692189887165,"gater":null},{"from":"18","to":"23","weight":0.0007821306120604221,"gater":null},{"from":"19","to":"24","weight":0.031697813235223304,"gater":null},{"from":"20","to":"24","weight":-0.0013868589419871596,"gater":null},{"from":"21","to":"24","weight":-0.09932088893838227,"gater":null},{"from":"22","to":"24","weight":-0.05772089576348663,"gater":null},{"from":"23","to":"24","weight":-0.00849244198761881,"gater":null}]

There are no from:null or to:null (gater can be null). So it seems to be working fine on my side.. aren't you doing anything else with that json after you call toJSON? Or are you modifying the Network after you call create_brain()? I also tested calling a few activate's and propagate before calling toJSON and the output is still right.

from synaptic.

Leekao avatar Leekao commented on August 20, 2024

I added another function to my prev post called "consumate" this is what I use to create random childs, maybe the problem is there?

from synaptic.

cazala avatar cazala commented on August 20, 2024

oh, yes, that's the problem. You are taking one layer from father network (hiddenLayer1) and projecting a connection to a layer from mothernetwork (hiddenLayer2), and then that layer projects a connection to hiddenLayer3 in child network. But those layers that you are taking already had projected connections (both were part of a network already). So you end up with layers that project half of their connections to the current network (child) and the other half to a different Network (father/mother), and when you call toJSON and the connections array is generated, the ID's in some of the Connection objects are not in the child network's neurons list (Network.neurons()) so they end up setted as null.

from synaptic.

Leekao avatar Leekao commented on August 20, 2024

Oh now I get it!
so I should remove all the projections from the mother/father layers before I use them to make the child?
can I even do that? can you suggest a better way of reaching the same goal?

from synaptic.

cazala avatar cazala commented on August 20, 2024

If what you want to achieve is some sort of cross-over between two Network's, what I'd recommend is to get both parents's jsons:

var mother_genes = mother_network.toJSON();
var father_genes = father_network.toJSON();

And then generate a child_genes json taking parts from those two json's, like:

var child_genes = { neurons: [], connections: [] };

for (var n in mother_genes.neurons)
    child_genes.neurons.push(Math.random() < .5 ? mother_genes.neurons[n] : father_genes.neurons[n]);

for (var c in mother_genes.connections)
    child_genes.connections.push(Math.random() < .5 ? mother_genes.connections[c] : father_genes.connections[c]);

Or you could also interpolate the values from the parents json's, or separate the props you pick from each in a different way, I don't know that's up to you (just make sure that it has the same amount of neurons and connections otherwise it will fail later when calling fromJSON).

And then you just generate a new network like this:

var child_network = Network.fromJSON(child_genes);

Note: this would only work if both parent networks have the same amount of layers, and the same number of neurons on each layer

from synaptic.

Leekao avatar Leekao commented on August 20, 2024

Yeah, I like this idea, I think that's exactly what I'm going to do. thank you so much man.

from synaptic.

cazala avatar cazala commented on August 20, 2024

no problem (;

from synaptic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.