Re: Templates args

2016-07-14 Thread Andrey via Digitalmars-d-learn
On Thursday, 14 July 2016 at 19:48:38 UTC, ag0aep6g wrote: Make F an alias parameter: struct Neurons_layer(T = float, size_t neurons_num = 0, alias F = Sigmoid) if(isFloatingPoint!T && is(typeof(F!T.Function))) { ... private: alias Function = F!T.Function; } unittest {

Re: Templates args

2016-07-14 Thread Andrey via Digitalmars-d-learn
On Thursday, 14 July 2016 at 19:48:20 UTC, Lodovico Giaretta wrote: You don't need Sigmoid!float at all. This will work: Neurons_layer!(float, 5) nf; as you provided a default value for the third argument. Yes, default init is present, but double, real types are desirable

Re: Templates args

2016-07-14 Thread ag0aep6g via Digitalmars-d-learn
On Thursday, 14 July 2016 at 19:28:23 UTC, Andrey wrote: On Thursday, 14 July 2016 at 19:27:14 UTC, Andrey wrote: [...] struct Sigmoid(T) { [...] } struct Neurons_layer(T = float, size_t neurons_num = 0, F = Sigmoid!T) if(isFloatingPoint!T && is(typeof(F.Function))) { [...] pri

Re: Templates args

2016-07-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/14/16 3:28 PM, Andrey wrote: On Thursday, 14 July 2016 at 19:27:14 UTC, Andrey wrote: struct Neurons_layer(T = float, size_t neurons_num = 0, F = Sigmoid!T) if(isFloatingPoint!T && is(typeof(F.Function))) { private: static if(neurons_num > 0) T[neurons_num] _neurons_ar

Re: Templates args

2016-07-14 Thread Lodovico Giaretta via Digitalmars-d-learn
On Thursday, 14 July 2016 at 19:28:23 UTC, Andrey wrote: On Thursday, 14 July 2016 at 19:27:14 UTC, Andrey wrote: Hi guys! Help a newbie please. Playing with D and trying to understand some features. Here is my try to carry out my code from C++ project to D struct Sigmoid(T) { const T Funct

Re: Templates args

2016-07-14 Thread Andrey via Digitalmars-d-learn
On Thursday, 14 July 2016 at 19:27:14 UTC, Andrey wrote: Hi guys! Help a newbie please. Playing with D and trying to understand some features. Here is my try to carry out my code from C++ project to D struct Sigmoid(T) { const T Function(T value) { ... } const T DerivateFunction(con

Templates args

2016-07-14 Thread Andrey via Digitalmars-d-learn
Hi guys! Help a newbie please. Playing with D and trying to understand some features. Here is my try to carry out my code from C++ project to D struct Sigmoid(T) { const T Function(T value) { ... } const T DerivateFunction(const T value) { ... } } struct Neurons_layer(T = flo