00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "ANN_node.h"
00020
00021
00022 using std::ostringstream;
00023
00024 using namespace Marsyas;
00025
00026 ANN_node::ANN_node(mrs_string name):MarSystem("ANN_node", name)
00027 {
00028
00029
00030
00031 addControls();
00032 }
00033
00034
00035 ANN_node::~ANN_node()
00036 {
00037 }
00038
00039
00040 MarSystem*
00041 ANN_node::clone() const
00042 {
00043 return new ANN_node(*this);
00044 }
00045
00046 void
00047 ANN_node::addControls()
00048 {
00049 addctrl("mrs_realvec/weights", weights_);
00050 setctrlState("mrs_realvec/weights", true);
00051 addctrl("mrs_real/bias", bias_);
00052 setctrlState("mrs_real/bias", true);
00053 }
00054
00055 void
00056 ANN_node::myUpdate(MarControlPtr sender)
00057 {
00058 (void) sender;
00059 MRSDIAG("ANN_node.cpp - ANN_node:myUpdate");
00060
00061 setctrl("mrs_natural/onSamples", getctrl("mrs_natural/inSamples"));
00062 setctrl("mrs_natural/onObservations", (mrs_natural)1);
00063 setctrl("mrs_real/osrate", getctrl("mrs_real/israte"));
00064
00065
00066 weights_ = getctrl("mrs_realvec/weights")->to<mrs_realvec>();
00067 bias_ = getctrl("mrs_real/bias")->to<mrs_real>();
00068 }
00069
00070 void
00071 ANN_node::myProcess(realvec& in, realvec& out)
00072 {
00073 mrs_natural o,t;
00074
00075
00076 for (t = 0; t < inSamples_; t++)
00077 {
00078 out(0,t) = bias_;
00079
00080 for (o=0; o < inObservations_; o++)
00081 {
00082 out(0,t) += weights_(o) * in(o,t);
00083 }
00084
00085 }
00086 }
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098