コード例 #1
0
ファイル: expD4.py プロジェクト: kryptine/anne
 def FoN(inputs, outputs):
     seed(tmpObject.i)
     tmpObject.i = tmpObject.i + 1
     m = MultilayerPerceptron(inputs, nbHidden, outputs, learning_rate=lrate, momentum=momentum, grid=mode)
     m.init_weights_randomly(-1, 1)
     tmpObject.net = m
     return m
コード例 #2
0
 def SoN(inputs, outputs):
     n = MultilayerPerceptron(nbHidden,
                              20,
                              2,
                              learning_rate=0.15,
                              momentum=0.5,
                              grid=mode)
     n.init_weights_randomly(-1, 1)
     return n
コード例 #3
0
 def SoN(inputs, outputs):
     return MultilayerPerceptron(inputs // 4,
                                 inputs // 2,
                                 inputs + inputs // 4 + outputs,
                                 learning_rate=lrate,
                                 momentum=momentum,
                                 grid=mode)
コード例 #4
0
 def SoN(inputs, outputs):
     return MultilayerPerceptron(nbr_hidden,
                                 nbr_hidden * 2,
                                 inputs + nbr_hidden + outputs,
                                 learning_rate=lrate,
                                 momentum=momentum,
                                 grid=mode)
コード例 #5
0
ファイル: expF2.py プロジェクト: kryptine/anne
 def SoN(inputs, outputs):
     return MultilayerPerceptron(nbHidden,
                                 20,
                                 2,
                                 learning_rate=0.1,
                                 momentum=0.,
                                 grid=mode)
コード例 #6
0
ファイル: representation.py プロジェクト: kryptine/anne
 def FoN2(inputs, outputs):
     return MultilayerPerceptron(inputs,
                                 inputs // 4,
                                 outputs,
                                 learning_rate=lrate,
                                 momentum=momentum,
                                 grid=mode)
コード例 #7
0
 def SoN(inputs, outputs):
     tmpObject.last2 = MultilayerPerceptron(inputs // 4,
                                            inputs // 2,
                                            inputs + inputs // 4 + outputs,
                                            learning_rate=lrate,
                                            momentum=momentum,
                                            grid=mode)
     return tmpObject.last2
コード例 #8
0
ファイル: expG1.py プロジェクト: kryptine/anne
 def control(inputs, outputs):
     seed(tmpObject.i)
     tmpObject.i = tmpObject.i + 1
     tmpObject.control = MultilayerPerceptron(inputs,
                                              nbHidden,
                                              outputs,
                                              learning_rate=lrate,
                                              momentum=momentum,
                                              grid=mode)
     tmpObject.control.init_weights_randomly(-1, 1)
     return tmpObject.control
コード例 #9
0
from data import DataFile

if __name__ == '__main__':
    mode = MultilayerPerceptron.R0to1
    nbr_network = 5
    momentum = 0.5
    nbEpoch = 201
    nbTry = 50
    display_interval = range(nbEpoch)[3::5]
    
    #create all networks
    networks = [{} for _ in range(nbr_network)]
    
    for i in range(nbr_network):
        seed(i)
        first_order = MultilayerPerceptron(16 * 16, 100, 10, learning_rate=0.15, momentum=momentum, grid=mode)
        first_order.init_weights_randomly(-1, 1)
        high_order_h = PRenforcement(100, temperature=1.)
        
        networks[i] = {'first_order' : first_order,
                    'high_order_h' : high_order_h}

    #create example
    examples = DataFile("digit_handwritten_16.txt", mode)

    #3 curves
    y_plot = {'first_order' : [] ,
              'high_order_h' : [],
              'high_order_l': []}

    y_perfo = {'first_order' : [] ,
コード例 #10
0
ファイル: IGT.py プロジェクト: matthieu637/anne
        return (True, random() < 0.7)
    else: 
        return (False, random() < 0.3)

if __name__ == '__main__':
    
    plt.title("low")
    grid = MultilayerPerceptron.R0to1
    nbr_network = 30
    nbr_epoch = 200
    nbr_trial = 10
    
    first_order = []
    high_order = []
    for _ in range(nbr_network):
        fo = MultilayerPerceptron(5, 40, 4, grid, 0.002, 0., 1., False, True)
        fo.init_weights_randomly(-1, 1)
        first_order.append(fo)
        
        #0.0003 or 0.015
        ho = MultilayerPerceptron(40, 40, 2, grid, 0.0003, 0., 1., False, True)
        ho.init_weights_randomly(-1, 1)
        high_order.append(ho)
    
    
    #trials
    wins = []
    wagers = []
    
    last_output = [ [0 for _ in range(5)] for _ in range(nbr_network)]
    for epoch in range(nbr_epoch):
コード例 #11
0
def pattern_to_list(pat):
    res = []
    for i in range(8):
        res.append(index_max(pat[i * 6:i * 6 + 6]))
    return res


if __name__ == '__main__':

    ptrain_pattern = [random_pattern() for _ in range(80)]

    #    print(ptrain_pattern[0][0])
    #    print(pattern_to_list(ptrain_pattern[0][0]))
    #    exit()

    first_order = MultilayerPerceptron(48, 40, 48, 0, 0.4, 0.5, 1., False,
                                       True)
    first_order.init_weights_randomly(-1, 1)

    high_order = [
        PerceptronR0to1(48, 0.4, 0.5, 1., Perceptron.OUTPUT, False, True)
        for _ in range(2)
    ]
    #    high_order = [PerceptronN0to1(48, 0.4, 0.5, False) for _ in range(2)]
    high_order[0].init_weights_randomly(0., 0.1)
    high_order[1].init_weights_randomly(0., 0.1)

    print("pre-training")
    err = 0.
    the = 0.
    rms = []
    rms2 = []
コード例 #12
0
ファイル: expC1.py プロジェクト: matthieu637/anne
 def SoN(inputs, outputs):
     n = MultilayerPerceptron(nbHidden, 20, 2, learning_rate=0.15, momentum=0.5, grid=mode)
     n.init_weights_randomly(-1, 1)
     return n
コード例 #13
0
ファイル: IGT_real.py プロジェクト: kryptine/anne
    else:
        return (False, random() < 0.2)


if __name__ == '__main__':

    grid = MultilayerPerceptron.R0to1
    nbr_network = 50
    nbr_epoch = 200
    nbr_trial = 10
    displays = range(nbr_epoch)[::5]

    first_order = []
    high_order = []
    for _ in range(nbr_network):
        fo = MultilayerPerceptron(5, 40, 4, grid, 0.002, 0., 1., False, True)
        fo.init_weights_randomly(-1, 1)
        first_order.append(fo)

        #0.0003 or 0.015
        ho = MultilayerPerceptron(40, 40, 2, grid, 0.015, 0., 1., False, True)
        ho.init_weights_randomly(-1, 1)
        high_order.append(ho)

    #trials
    wins = []
    wagers = []

    last_output = [[0 for _ in range(5)] for _ in range(nbr_network)]
    for epoch in range(nbr_epoch):
        nbr_win = 0
コード例 #14
0
    #    examples = DataFileR("iris.txt")
    momentum = 0.9

    nbInputs = len(examples.inputs[0])
    nbHidden = 10
    nbOutputs = len(examples.outputs[0])
    nbShape = nbOutputs

    #create all networks
    networks = [{} for _ in range(nbr_network)]

    for i in range(nbr_network):
        first_order = MultilayerPerceptron(nbInputs,
                                           nbHidden,
                                           nbOutputs,
                                           learning_rate=lrate,
                                           momentum=momentum,
                                           grid=mode)
        high_order_10 = MultilayerPerceptron(nbHidden,
                                             nbHidden * 2,
                                             nbInputs + nbHidden + nbOutputs,
                                             learning_rate=lrate,
                                             momentum=momentum,
                                             grid=mode)

        networks[i] = {
            'first_order': first_order,
            'high_order_10': high_order_10
        }

    learned = [[0 for _ in range(nbShape)] for _ in range(nbDiscre**nbHidden)]
コード例 #15
0
 def FoN(inputs, outputs):
     tmpObject.last = MultilayerPerceptron(inputs, nbr_hidden, outputs, learning_rate=lrate, momentum=momentum, grid=mode)
     return tmpObject.last
コード例 #16
0
if __name__ == '__main__':
    mode = MultilayerPerceptron.R0to1
    nbr_network = 5
    momentum = 0.9
    lrate = 0.1
    nbEpoch = 1000
    display_interval = [0, 25, 50, 100, 200, 500, 999]
    display_interval2 = range(nbEpoch)[::7]

    #create all networks
    networks = [{} for _ in range(nbr_network)]

    for i in range(nbr_network):
        first_order = MultilayerPerceptron(20,
                                           5,
                                           10,
                                           learning_rate=lrate,
                                           momentum=momentum,
                                           grid=mode)
        high_order_10 = MultilayerPerceptron(5,
                                             10,
                                             35,
                                             learning_rate=lrate,
                                             momentum=momentum,
                                             grid=mode)
        high_order_5 = MultilayerPerceptron(5,
                                            5,
                                            35,
                                            learning_rate=lrate,
                                            momentum=momentum,
                                            grid=mode)
コード例 #17
0
    mode = MultilayerPerceptron.R0to1
    nbr_network = 5
    momentum = 0.5
    nbEpoch = 201
    nbTry = 50
    display_interval = range(nbEpoch)[3::5]
    seed(100)

    #create all networks
    networks = [{} for _ in range(nbr_network)]

    for i in range(nbr_network):
        seed(i)
        control = MultilayerPerceptron(16 * 16,
                                       100,
                                       10,
                                       learning_rate=0.15,
                                       momentum=momentum,
                                       grid=mode)
        control.init_weights_randomly(-1, 1)

        high_order_h = MultilayerPerceptron(100,
                                            20,
                                            2,
                                            learning_rate=0.1,
                                            momentum=0.,
                                            grid=mode)
        first_order = AdHock(control)

        networks[i] = {
            'first_order': first_order,
            'high_order_h': high_order_h,
コード例 #18
0
ファイル: merging_gradient.py プロジェクト: kryptine/anne
if __name__ == '__main__':
    mode = MultilayerPerceptron.R0to1
    nbr_network = 5
    momentum = 0.5
    nbEpoch = 201
    nbTry = 50
    display_interval = range(nbEpoch)[3::5]
    
    
    #create all networks
    networks = [{} for _ in range(nbr_network)]
    
    for i in range(nbr_network):
        seed(i)
        control = MultilayerPerceptron(16 * 16, 100, 10, learning_rate=0.15, momentum=momentum, grid=mode,
                                       temperature=1, random=False, enable_bias=True)
        control.init_weights_randomly(-1, 1)
        
        first_order = AdHock(control)
        
        networks[i] = {'first_order' : first_order,
                    'control': control}

    #create example
    examples = DataFile("digit_handwritten_16.txt", mode)

    #3 curves
    y_perfo = {'first_order' : [] ,
              'high_order_h' : [],
              'wager_proportion': [],
              'feedback' : [],
コード例 #19
0
ファイル: main.py プロジェクト: kryptine/anne
import matplotlib.pyplot as plt
from data import DataFile

if __name__ == '__main__':
    mode = MultilayerPerceptron.R0to1
    nbr_network = 5
    momentum = 0.5
    nbEpoch = 201
    display_interval = range(nbEpoch)[3::5]
    
    #create all networks
    networks = [{} for _ in range(nbr_network)]
    
    
    for i in range(nbr_network):
        first_order = MultilayerPerceptron(7, 100, 10, learning_rate=0.15, momentum=momentum, grid=mode)
        high_order_h = MultilayerPerceptron(100, 100, 2, learning_rate=0.1, momentum=0, grid=mode)
        high_order_l = MultilayerPerceptron(100, 100, 2, learning_rate=10e-7, momentum=0, grid=mode)
        
        networks[i] = {'first_order' : first_order,
                    'high_order_h' : high_order_h,
                    'high_order_l' : high_order_l}
    
    for network in networks:
        for k in network.keys():
            if(k == 'first_order'):
                network[k].init_weights_randomly(-1, 1)

    #create example
    examples = DataFile("digital_shape.txt", mode)
コード例 #20
0
ファイル: AGL.py プロジェクト: matthieu637/anne
def pattern_to_list(pat):
    res = []
    for i in range(8):
        res.append(index_max(pat[i * 6 : i * 6 + 6]))
    return res


if __name__ == "__main__":

    ptrain_pattern = [random_pattern() for _ in range(80)]

    #    print(ptrain_pattern[0][0])
    #    print(pattern_to_list(ptrain_pattern[0][0]))
    #    exit()

    first_order = MultilayerPerceptron(48, 40, 48, 0, 0.4, 0.5, 1.0, False, True)
    first_order.init_weights_randomly(-1, 1)

    high_order = [PerceptronR0to1(48, 0.4, 0.5, 1.0, Perceptron.OUTPUT, False, True) for _ in range(2)]
    #    high_order = [PerceptronN0to1(48, 0.4, 0.5, False) for _ in range(2)]
    high_order[0].init_weights_randomly(0.0, 0.1)
    high_order[1].init_weights_randomly(0.0, 0.1)

    print("pre-training")
    err = 0.0
    the = 0.0
    rms = []
    rms2 = []

    nbEpoch = 60