From: Janek Kozicki (janek_listy_at_[hidden])
Date: 2007-01-02 08:44:57
Gunter Winkler said: (by the date of Tue, 2 Jan 2007 12:29:15 +0100)
> Am Dienstag, 2. Januar 2007 09:27 schrieb Janek Kozicki:
> > a very good point. We could start with my inefficient implementation,
> > however, since it directly affects the speed of parallel computations
> > I hope that someone will came up with a more efficient
> > implementation. :)
> Can you post a short example program that uses serialization?
If you want a very-short but compilable and runnable example of
serialization usage, just look at the serialization tutorial:
If you want an example of using ublas matrix and vectors in
serialization look at my neural network simulation:
A snippet from the code:
typedef double Precision;
// actual values at neurons
typedef boost::numeric::ublas::vector<Precision> Layer;
// weights which connect layers
typedef boost::numeric::ublas::matrix<Precision> Weight;
typedef std::vector<Layer> Layers;
typedef std::vector< Weight > Weights;
/* ... */
This is a fully working neural network, you can train it, *save* the
trained neural network that has learned something, at any later time
*load* it and use to do the actual work.
Neural network operates, among other things, by multiplying layers
(vector) by weights (matrix). And calculating some gradient, etc...
This has extensive tutorial inside, so you can try it out if you want :)
This code is not using serialization for ublas matrix and vector,
because it's not part of official boost library. Instead it uses
very cumbersome and lenghty loops. Additionaly the srialization had to
be split into separate calls "save()" and "load()", which doubled the
amount of code. Each of those loops could be simply replaced by a
single line. And "load()" and "save()" could be merged into a single
function with 7 lines.
If I could use ublas serialization, the file
NeuralNetworkSerialize.hpp would have 15 lines instead of 75 lines.
Don't you think it's annoying? ;>>
-- Janek Kozicki |