From: Mathieu D. <mat...@li...> - 2009-03-13 12:23:06
|
[Sorry I forgot to send the response to the list] Hi Dejan, Thanks to your remark I have realised my error! In a previous version I used "linear_sum" and wrote the python with this name. I later changed the C++ member to "linear_input" but not the python code. It was a stupid mistake :( I have updated the code and I can now record the field. However, I would like to create a member function double getLinearInput(void) that returns the value of the member "linear_input" (in the same vein as getAnalogOutput()). How do I have to declare it? I have tried the following declaration double getLinearInput(void) { return this->linear_input;}; (see attachments) but when I try to use it I get the following error: ArgumentError: Python argument types in SquashingNeuron.getLinearInput(SquashingNeuron) did not match C++ signature: getLinearInput(SquashingNeuron {lvalue}) I have seen that AnalogPointNeuron::getAnalogOutput is declared as follows: virtual double <http://www.lsm.tugraz.at/pcsim/cppclassreference/html/classdouble.html> getAnalogOutput <http://www.lsm.tugraz.at/pcsim/cppclassreference/html/classAnalogPointNeuron.html#a6e02306ef9cd057f844615691b9293f> (analog_port_id_t <http://www.lsm.tugraz.at/pcsim/cppclassreference/html/globaldefinitions_8h.html#40dfc683bdf73c81c9c73726fc834feb> port=0) const Is it necessary to declare the function virtual (I'm not a C++ expert :) ? Thank you again & sorry for the trouble, Mathieu Pecevski Dejan wrote: > Hi Mathieu, > > I've looked at your code. > Do you mean the linear_input public member in the SquashingNeuron > function, instead of linear_sum? > Did you try the linear_input member or linear_sum? > > regards, > Dejan > > > Mathieu Dubois wrote: >> Hi everybody, >> >> I'm developing a small PCSIM extension (I have carefully followed the >> steps in the HowTo). >> >> I want to define a new class SquashingNeuron which derives from >> LinearNeuron. At each step it should sum the synaptic inputs (like >> LinearNeuron) and apply a squashing function. >> >> The implementation is straightforward (see attachments). Compilation >> & tests went fine. >> >> However (for debugging purpose) I would like to be able to record the >> "linear_sum" public member (which is the linear sum of synaptic >> inputs - result of LinearNeuron::advance(...) see code). >> >> When I try this I get the following error message: >> >> RuntimeError: PCSIM::Exception in function SimObject::findField: >> SquashingNeuron has no field named linear_sum >> >> Is there something wrong with my code or do I have to do something to >> turn a C++ public member into a PCSIM field? >> >> Interested readers will recognize the kind of squashing function used >> in the p-delta learning rule... which is what I would like to implement. >> >> Thanks in advance, >> Mathieu >> ------------------------------------------------------------------------ >> >> #include "SquashingNeuron.h" >> >> // SquashingNeuron::SquashingNeuron(): rho(DEFAULT_RHO) { >> // } >> >> SquashingNeuron::SquashingNeuron(double rho): rho(rho) { >> } >> >> int SquashingNeuron::advance(AdvanceInfo const & info) { >> LinearNeuron::advance(info); >> linear_input = this->Vm; >> if (linear_input < -this->rho) { >> this->Vm = POSITIVE_OUTPUT; >> } >> if ((linear_input >= -this->rho) && (linear_input <= this->rho)) { >> this->Vm = linear_input/this->rho; >> } >> if (linear_input > this->rho) { >> this->Vm = NEGATIVE_OUTPUT; >> } >> return 0; >> } >> >> ------------------------------------------------------------------------ >> >> #ifndef SQUASHINGNEURON_H_ >> #define SQUASHINGNEURON_H_ >> >> #include "LinearNeuron.h" >> >> #define POSITIVE_OUTPUT (1) >> #define NEGATIVE_OUTPUT (-1) >> >> #define DEFAULT_RHO (0.25) >> >> class SquashingNeuron : public LinearNeuron >> { >> >> SIMOBJECT( SquashingNeuron, AdvancePhase::Two ) >> >> public: >> // SquashingNeuron(); >> SquashingNeuron(double rho = DEFAULT_RHO); >> >> int advance(AdvanceInfo const &); >> >> double linear_input; >> >> protected: >> double rho; >> }; >> >> #endif /*SQUASHINGNEURON_H_*/ >> >> ------------------------------------------------------------------------ >> >> ------------------------------------------------------------------------------ >> Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are >> powering Web 2.0 with engaging, cross-platform capabilities. Quickly and >> easily build your RIAs with Flex Builder, the Eclipse(TM)based development >> software that enables intelligent coding and step-through debugging. >> Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> Pcsim-users mailing list >> Pcs...@li... >> https://lists.sourceforge.net/lists/listinfo/pcsim-users >> > > > -- > _______________________________________________ > Dejan Pecevski > Institute for Theoretical Computer Science > Graz University of Technology > Inffeldgasse 16b, A-8010 Graz, Austria > Tel. +43 316 873 5849 > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------------ > Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are > powering Web 2.0 with engaging, cross-platform capabilities. Quickly and > easily build your RIAs with Flex Builder, the Eclipse(TM)based development > software that enables intelligent coding and step-through debugging. > Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com > ------------------------------------------------------------------------ > > _______________________________________________ > Pcsim-users mailing list > Pcs...@li... > https://lists.sourceforge.net/lists/listinfo/pcsim-users > |