Teaching myself scripting and this is a fairly basic Neuron it will switch
between the +/- 'start' parameter every 'time' parameter.
Example X[Switch,start:0.5,time:50]
I know its simple and I'd appreciate it if you tell me if i did something
wrong.
~copy and paste into Switch.neuro~
class:
name:Switch
longname:Switching Neuron
prefinputs:-1
prefoutput:1
description:takes no input, has one output. flips between negative and
positive 'start' value every 'time' value
code:~
function init() {
Neuro.state=NeuroProperties.start;
NeuroProperties.count = 0;
}
function go()
{
if (NeuroProperties.count >= NeuroProperties.time)
{Neuro.state = Neuro.state * -1;
NeuroProperties.count = 0;
}
else
NeuroProperties.count = NeuroProperties.count + 1;
}
~
property:
id:start
name:starting value
type:f -1.0 1.0
property:
id:count
name:time tracker internal
type:d
property:
id:time
name:how often to switch
type:d 1 1000
Re: Switching Neuron
[...]
> I know its simple and I'd appreciate it if you tell me if i did something
> wrong.
the script is ok! :-)
i have only 2 remarks:
- "prefinput" should be zero (this doesn't influence the neuron itself
but is used by genetic operators - let them know your neuron doesn't use
any inputs)
- *.neuro file syntax: "~" character can be used to make framsticks read
long (multiline) fields. "description" has now 2 lines (because of the
newsreader's word-wrapping?) and only the first line is actually read.
but it can be written with the "~" syntax, like the "code" field:
description:~
takes no input, has one output. flips between negative and
positive 'start' value every 'time' value~
special bonus:
put this into your switch.neuro file to get a nice "square wave
generator" icon in the NN diagram :-)
vectordata:~
46,3,12,75,50,71,37,62,28,50,25,37,28,28,37,25,50,28,62,37,71,50,75,62,71,71,62,75,50,1,75,50,100,50,5,35,50,35,40,50,40,50,60,65,60,65,50~
sz.