cazala / synaptic

architecture-free neural network library for node.js and the browser
http://caza.la/synaptic
Other
6.91k stars 666 forks source link

Layers to JSON #203

Closed havenS closed 7 years ago

havenS commented 7 years ago

Hi,

I'm new to synaptic and, more globally, to NN so please excuse my lack of knowledge. I'm using Layers, once trained, I'd like to store it like it's done for Network (toJSON()) but I can't see how to do it. Do I have to create a network with those Layers to get the JSON ? If so, can I get my Layers back decoupled after using fromJSON() ? Thank you very much for all you work.

wagenaartje commented 7 years ago

There is no to/fromJSON function for layers. If you just have a standalone layer, you could save the the neuron biases manually. If you have connections to the layer (implying you have multiple layers), then you can form a network out of it and make a json from it.

havenS commented 7 years ago

Hi @wagenaartje thank you for your answer, I'm not event 100% sure of my current setup. I'll continue to explore other options like the network. Cheers

wagenaartje commented 7 years ago

@havenS

Oh, and just to clarify why there are no toJSON methods for layers or neurons. Because layers and neurons on themselves are connectionless! Yes, they might be connected, but when you convert a layer to a json file and back again then these connections are not 'connected'. Each connection has its own unique id and is referenced on 2 places; at the projecting neuron and at the receiving neuron. If you just convert one of these neurons to json, then you will only have half of the connection -> thus the connection is dead.

However, if youre goal is really just to save neuron biases in a layer, then take a look at my extended synaptic library, Gynaptic it includes a toJSON() and fromJSON() for layers and neurons!

havenS commented 7 years ago

Thank you very much for the explanation. In fact, I easily reproduced my Layers setup with the Network and thus was able to save to JSON. I'll check on Gynaptic if the need to save Layers shows up again. Anyway thank you again for the time you spent answering me. Cheers