Пример #1
0
def buildExperiment(ind):
    net=nef.Network('EA designed recurrent SNN')  
    net.add_to_nengo();
    # generator
    # function .1 base freq, max freq 10 rad/s, and RMS of .5; 12 is a seed
    generator=FunctionInput('generator',[FourierFunction(.1, 5,.3, 12),
        FourierFunction(.5, 7, .7, 112)],Units.UNK) 
    net.add(generator);

    # model
    model= buildModel(ind);
    net.add(model.network); 

    # plant
    plant = net.add(modules.OR('Fuzzy OR'));

    # error estimation
    err = net.make('error',1,1,mode='direct');
    mse = net.add(modules.mse('MSE'));

    # wiring
    modelIn = model.get('inputs');  # get the input model
    model.network.exposeTermination(modelIn.getTermination('in'),'subInput'); # expose its termination
    net.connect(generator,model.network.getTermination('subInput'),weight=1)  # generator to termination
    net.connect(generator,plant.getTermination('inputs'))                     # generator to plant

    modelOut = model.get('outputt');
    model.network.exposeOrigin(modelOut.getOrigin('out'),'subOutput');        # expose its termination
    net.connect(model.network.getOrigin('subOutput'), err, weight=-1)

    net.connect(plant.getOrigin('output'),err)  
    net.connect(err,mse.getTermination('error'))
    return net;
Пример #2
0
def buildExperiment(ind):
    net=nef.Network('EA designed recurrent SNN')  
    net.add_to_nengo();
    # generator
    # function .1 base freq, max freq 10 rad/s, and RMS of .5; 12 is a seed
    generator=FunctionInput('generator',[FourierFunction(.1, 5,.3, 12),
        FourierFunction(.5, 7, .7, 112)],Units.UNK)
    net.add(generator);

    # model
    model= buildModel(ind);
    net.add(model.network); 

    # plant
    plant = net.add(modules.OR('Fuzzy OR'));
    #plant = net.add(mathNodes.SUMABS('SUM'));
    # error estimation
    err = net.make('error',1,1,mode='direct');
    mse = net.add(modules.mse('MSE'));

    # wiring
    modelIn = model.get('inputs');  # get the input model
    model.network.exposeTermination(modelIn.getTermination('in'),'subInput'); # expose its termination
    net.connect(generator,model.network.getTermination('subInput'),weight=1)  # generator to termination
    net.connect(generator,plant.getTermination('inputs'))                     # generator to plant

    modelOut = model.get('outputt');
    model.network.exposeOrigin(modelOut.getOrigin('out'),'subOutput');        # expose its termination
    net.connect(model.network.getOrigin('subOutput'), err, weight=-1)

    net.connect(plant.getOrigin('output'),err)  
    net.connect(err,mse.getTermination('error'))
    return net;
Пример #3
0
def buildExperiment(w):
    # PARENT NETWORK
    net=nef.Network('SimpleModule tries to approximate the Plant')  
    net.add_to_nengo();
    
    # SIGNAL GENERATOR
    # function .1 base freq, max freq 10 rad/s, and RMS of .5; 12 is a seed
    generator=FunctionInput('generator',[FourierFunction(.1, 5,.3, 12),
        FourierFunction(.5, 7, .7, 112)],Units.UNK)
    net.add(generator);

    # PLANT
    # can be implemented by anything (external process, signal generator, dataset..)
    plant = net.add(modules.OR('Plant - Fuzzy OR'));
    
    # MODEL
    model=net.add(Model('model',2,1,3))             # system with no. of inputs,outputs,pars.
    const=net.make_input('Constant',[0.2,0.4,0.6])  # set the parameters of the model
    net.connect(const,model.getTermination('params'));

    # ERROR estimation
    err = net.make('error',1,1,mode='direct');
    mmse = net.add(modules.mse('MSE'));

    # WIRING it together
    net.connect(generator,model.getTermination('inputs'))   # generator to model
    net.connect(generator,plant.getTermination('inputs'))   # generator to plant

    net.connect(model.getOrigin('outputs'), err, weight=-1) # model to error (negative value)
    net.connect(plant.getOrigin('output'), err, weight=+1)  # plant to error 

    net.connect(err,mmse.getTermination('error'))           # actual error to MSE

    return net;
Пример #4
0
def buildExperiment(ind):
    net = nef.Network("EA designed recurrent HNN")
    net.add_to_nengo()
    # generator
    # function .1 base freq, max freq 10 rad/s, and RMS of .5; 12 is a seed
    generator = FunctionInput(
        "generator", [FourierFunction(0.1, 5, 0.3, 12), FourierFunction(0.5, 7, 0.7, 112)], Units.UNK
    )
    net.add(generator)
    # model
    model = buildNeurons(net, ind.getMatrix().getN())
    net.add(model.network)
    # plant
    plant = net.add(modules.OR("Fuzzy OR"))
    # plant = net.add(mathNodes.SUMABS('SUM'));
    # error estimation
    err = net.make("error", 1, 1, mode="direct")
    mse = net.add(modules.mse("MSE"))
    # wiring
    modelIn = model.get("inputs")
    # get the input model
    model.network.exposeTermination(modelIn.getTermination("in"), "subInput")
    # expose its termination
    net.connect(generator, model.network.getTermination("subInput"), weight=1)  # generator to termination
    net.connect(generator, plant.getTermination("inputs"))  # generator to plant
    #
    modelOut = model.get("outputt")
    model.network.exposeOrigin(modelOut.getOrigin("out"), "subOutput")
    # expose its termination
    net.connect(model.network.getOrigin("subOutput"), err, weight=-1)
    #
    net.connect(plant.getOrigin("output"), err)
    net.connect(err, mse.getTermination("error"))
    return net
Пример #5
0
def buildExperiment(ind):
    net=nef.Network('IO neuron transfer fcn test')  
    net.add_to_nengo();
    # generator
    # function .1 base freq, max freq 10 rad/s, and RMS of .5; 12 is a seed
    generator=FunctionInput('generator',[FourierFunction(.1, 12,.3, 12),
        FourierFunction(.5, 20, .7, 112)],Units.UNK) 
    net.add(generator);

    # model
    model= buildModel(ind);
    net.add(model.network); 

    # plant
    plant = net.add(modules.OR('Fuzzy OR'));

    # error estimation
    err = net.make('error',1,1,mode='direct');
    mse = net.add(modules.mse('MSE'));

    # wiring
    net.connect(generator,'model.input',weight=1) # feed the signal into plant and model
    net.connect(generator,plant.getTermination('inputs'))

    net.connect('model.output',err,weight=-1)
    net.connect(plant.getOrigin('output'),err)                     # compute difference
    net.connect(err,mse.getTermination('error'))
    return net;
Пример #6
0
def buildExperiment(w):
    # PARENT NETWORK
    net=nef.Network('Simple Model tries to approximate the Plant')  
    net.add_to_nengo();
    
    # SIGNAL GENERATOR
    # function .1 base freq, max freq 10 rad/s, and RMS of .5; 12 is a seed
    generator=FunctionInput('generator',[FourierFunction(.1, 5,.3, 12),
        FourierFunction(.5, 7, .7, 112)],Units.UNK)
    net.add(generator);

    # PLANT
    # can be implemented by anything (external process, signal generator, dataset..)
    plant = net.add(modules.OR('Plant - Fuzzy OR'));
    
    # MODEL
    model = net.add(modules.exampleDynamicSystem('Model - dynamic system'));
    # TODO: setup of parameter should work as weighted constant, as follows:
    #const=net.make_input('Constant',[10])  # Create a constant function
    #net.connect(const,model.getTermination('par_alpha'),weight=w);
    const=net.make_input('Constant',[w*10])  # ..This is temporary solution
    net.connect(const,model.getTermination('par_alpha'));

    # ERROR estimation
    err = net.make('error',1,1,mode='direct');
    mmse = net.add(modules.mse('MSE'));

    # WIRING it together
    net.connect(generator,model.getTermination('inputs'))   # generator to model
    net.connect(generator,plant.getTermination('inputs'))   # generator to plant

    net.connect(model.getOrigin('output'), err, weight=-1)  # model to error (negative value)
    net.connect(plant.getOrigin('output'), err, weight=+1)  # plant to error 

    net.connect(err,mmse.getTermination('error'))           # actual error to MSE

    return net;