Advertisement

Neural Network modeling

Started by August 28, 2009 02:38 PM
1 comment, last by SiS-Shadowman 15 years, 2 months ago
Hello everyone, I'm trying to write a general-purpose NN, and I'm actually at the abstract modeling phase. What I would like to achieve - if possible - is to keep logics and data completely separated, so that internal operations can be carried out indifferently as single or double floating point, as int (if it makes any sense) or even as a custom data format, like fixed point, so it can be ported on devices other than a PC. I modeled my network as classes like this: Network, Layer, TLU, DataCruncher, Threshold. DataCruncher (the actual data vector carrier) and Threshold are the only two classes that need to deal with data, so I thought them as templates. Other classes simply are a pyramid of logic. While implementing this model though, I found I had to templatize everything, making the library impossible to compile without any specialization, because - well - each object is a container for the others, like this: Network < Layer < TLU < Threshold and the final user will use the network by only operating on the outmost class: Network. So I need to pass a type T from Network down to Threshold, forcing me to templatize everything, like this: template <typename T> class Network { std::vector< Layer<T> > Layers; }; template <typename T> class Layer { std::vector< TLU<T> > TLUs; }; and so on. Do you suggest to just go on with the all-template thing, do you think I should reconsider everything, any suggestion? Thanks!
[ King_DuckZ out-- ]
My experience tells me that .. if you wish to work on faster algorithm and to avoid futuristic potential problem, you should avoid using template, instead.

As i for myself encountered a lot of problem in template which is not solvable and finally ended up rewritting the interface over.

Perhaps, i was wrong.



Take care.
Technical ..? then Master Non-Technical first ...
Advertisement
I used that approach when working on a math library and I can say that it worked well for me. My execution speed is behind others (DirectX for example) but I suspect that is because I don't use SSE instructions for my calculations.

However I don't see why using template classes would slow down execution speed. I really don't see any connection. I do know that it will slow down compilation speed, but that wasn't a big problem for me. I finally settled with this approach:

Create template classes like vector3<T>, matrix4x4<T>, Ray<T>, etc... and export them for single and double floating-point precision. This way I had most of my code compiled into a dll. Only template functions are not exported. So far this works like a charm.

This topic is closed to new replies.

Advertisement