convnetjs icon indicating copy to clipboard operation
convnetjs copied to clipboard

How can data be serialized?

Open MartinThoma opened this issue 9 years ago • 5 comments

Can a network that is already trained be serialized? In which format can it be serialized? Can I train a network with other tools and let convnetjs only read it?

MartinThoma avatar Nov 19 '14 20:11 MartinThoma

Hi Martin,

A network that was trained in ConvNetJS can be serialized with net.toJSON(), as mentioned in docs. And then loaded with net.fromJSON()

Currently there is no support for taking a net from other tools/libraries and converting them to ConvNetJS. I've converted Caffe Alexnet reference model in my own branch but it was too messy and hacky to release. So it's possible if you're willing but not very clean.

Andrej

On Wed, Nov 19, 2014 at 12:22 PM, Martin Thoma [email protected] wrote:

Can a network that is already trained be serialized? In which format can it be serialized? Can I train a network with other tools and let convnetjs only read it?

— Reply to this email directly or view it on GitHub https://github.com/karpathy/convnetjs/issues/21.

karpathy avatar Nov 19 '14 20:11 karpathy

Hi Andrej,

Thank you for the quick response.

I am working with neural networks for handwriting recognition (see http://martin-thoma.com/write-math/ if you are interested). I used a university-internal Python toolkit which is based on Theano to train with the GPU. The network in JSON format needs about 8.1 MiB which is much bigger than it needs to be because JSON doesn't store big float matrices efficiently. Do you have any idea of a "compressed" serialization format that works with JavaScript?

MartinThoma avatar Nov 19 '14 20:11 MartinThoma

Good question, I only had a brief look at some of these. bson and similar protocols seem like a possibility but I've never fully investigated it. I've also considered super hacky ways where I would create a regex over the JSON to manually trim all floats to only a few significant digits, since these networks don't need all that precision at test time (they do in train time)

Andrej

On Wed, Nov 19, 2014 at 12:30 PM, Martin Thoma [email protected] wrote:

Hi Andrej,

Thank you for the quick response.

I am working with neural networks for handwriting recognition (see http://martin-thoma.com/write-math/ if you are interested). I used a university-internal Python toolkit which is based on Theano to train with the GPU. The network in JSON format needs about 8.1 MiB which is much bigger than it needs to be because JSON doesn't store big float matrices efficiently. Do you have any idea of a "compressed" serialization format that works with JavaScript?

— Reply to this email directly or view it on GitHub https://github.com/karpathy/convnetjs/issues/21#issuecomment-63708077.

karpathy avatar Nov 19 '14 20:11 karpathy

Hi Andrej,

When you said that converted alexnet from Caffe, what made it messy? are there particular things that caffee does in alexnet that currently convnetjs doesn't support?

Jorge

torrmal avatar Mar 15 '15 20:03 torrmal

Yeah the more annoying one was group convolution (the parameter group:2). That's the point where I gave up because I was too lazy to implement it, although it probably would have been not too difficult.

In particular, the AlexNet is broken down into two streams due to historical reasons, since there were difficulties in fitting the full model on a single GPU. So with K filters looking at input volume of depth D, the first K/2 look at the first D/2 activation maps, and the other K/2 look at the other D/2 activation maps.

Andrej

On Sun, Mar 15, 2015 at 1:08 PM, Jorge Torres [email protected] wrote:

Hi Andrej,

When you said that converted alexnet from Caffe, what made it messy? are there particular things that caffee does in alexnet that currently convnetjs doesn't support?

Jorge

— Reply to this email directly or view it on GitHub https://github.com/karpathy/convnetjs/issues/21#issuecomment-81220171.

karpathy avatar Mar 15 '15 20:03 karpathy