libcompetitivefunctions.cpp
1 /********************************************************************************
2  * Neural Network Framework. *
3  * Copyright (C) 2005-2011 Gianluca Massera <emmegian@yahoo.it> *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the Free Software *
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
18  ********************************************************************************/
19 
21 #include <cmath>
22 
23 namespace farsa {
24 
26  : OutputFunction() {
27  valuev = value;
28 }
29 
31  valuev = v;
32  return true;
33 }
34 
36  return valuev;
37 }
38 
40  outputs.zeroing();
41  outputs[ maxIndex( inputs ) ] = valuev;
42 }
43 
45 {
46  valuev = 1.0;
47  QString str = params.getValue(prefix + "value");
48  if (!str.isEmpty()) {
49  bool ok;
50  valuev = str.toDouble(&ok);
51  if (!ok) {
52  valuev = 1.0;
53  }
54  }
55 }
56 
58 {
59  params.startObjectParameters(prefix, "WinnerTakeAllFunction", this);
60  params.createParameter(prefix, "value", QString::number(valuev));
61 }
62 
63 void WinnerTakeAllFunction::describe( QString type ) {
64  Descriptor d = addTypeDescription( type, "Winner Take All Output function" );
65  d.describeReal( "value" ).def(1.0).limits(1, +Infinity).help("The output value assumed by the winner (the most activated neuron); all other neurons will have 0.0 as output value");
66 }
67 
68 }
69