コード例 #1
0
def test2():
    state=PerceptronSharedState(40)
    gp1=GPerceptron.from_shared_state(state)
    gp2=GPerceptron.from_shared_state(state)
    gp3=GPerceptron.from_shared_state(state)
    print "GP1"
    print gp1.w
    print gp1.w_avg
    print gp1.w_avg_N
    print "-------------------------"
    gp1.update({"X":1.0, "Y":1.0},{"X":1.0,"Z":1.0},0.2,0.1,0.0)
    print gp1.w
    print gp1.w_avg
    print gp1.w_avg_N
    print
    print
    print "GP2"
    print gp2.w
    print gp2.w_avg
    print gp2.w_avg_N
    print "-------------------------"
    gp2.update({"X":1.0, "Y":1.0},{"X":1.0,"Z":1.0},0.2,0.1,0.0)
    print gp2.w
    print gp2.w_avg
    print gp2.w_avg_N
    print
    print
    print "GP3"
    print gp3.w
    print gp3.w_avg
    print gp3.w_avg_N
    print "-------------------------"
    gp3.update({"X":1.0, "Y":1.0},{"X":1.0,"Z":1.0},0.2,0.1,0.0)
    print gp3.w
    print gp3.w_avg
    print gp3.w_avg_N
    print
    print
    print "************* RELOAD *************"
    state.save("delme.s",True)
    state=PerceptronSharedState.load("delme.s",True)
    gp1=GPerceptron.from_shared_state(state)
    print gp1.w
    print gp1.w_avg
    print gp1.w_avg_N
コード例 #2
0
def test2():
    state = PerceptronSharedState(40)
    gp1 = GPerceptron.from_shared_state(state)
    gp2 = GPerceptron.from_shared_state(state)
    gp3 = GPerceptron.from_shared_state(state)
    print "GP1"
    print gp1.w
    print gp1.w_avg
    print gp1.w_avg_N
    print "-------------------------"
    gp1.update({"X": 1.0, "Y": 1.0}, {"X": 1.0, "Z": 1.0}, 0.2, 0.1, 0.0)
    print gp1.w
    print gp1.w_avg
    print gp1.w_avg_N
    print
    print
    print "GP2"
    print gp2.w
    print gp2.w_avg
    print gp2.w_avg_N
    print "-------------------------"
    gp2.update({"X": 1.0, "Y": 1.0}, {"X": 1.0, "Z": 1.0}, 0.2, 0.1, 0.0)
    print gp2.w
    print gp2.w_avg
    print gp2.w_avg_N
    print
    print
    print "GP3"
    print gp3.w
    print gp3.w_avg
    print gp3.w_avg_N
    print "-------------------------"
    gp3.update({"X": 1.0, "Y": 1.0}, {"X": 1.0, "Z": 1.0}, 0.2, 0.1, 0.0)
    print gp3.w
    print gp3.w_avg
    print gp3.w_avg_N
    print
    print
    print "************* RELOAD *************"
    state.save("delme.s", True)
    state = PerceptronSharedState.load("delme.s", True)
    gp1 = GPerceptron.from_shared_state(state)
    print gp1.w
    print gp1.w_avg
    print gp1.w_avg_N
コード例 #3
0
 def __init__(self,model_file_name,fName=None,gp=None,beam_size=40,test_time=False):
     self.test_time=test_time
     self.features=Features()
     self.beam_size=beam_size
     self.model=Model.load(model_file_name)
     if gp:
         self.perceptron=gp
         return
     elif fName is not None:
         self.perceptron_state=PerceptronSharedState.load(fName,retrainable=True)
     else:
         self.perceptron_state=PerceptronSharedState(5000000)
     self.perceptron=GPerceptron.from_shared_state(self.perceptron_state)
コード例 #4
0
def test1():
    state=PerceptronSharedState(10000)
    dist1=DataGen(1000)
    dist2=DataGen(1000)
    PS=[]
    for x in range(8):
        newGP=GPerceptron.from_shared_state(state)
        p=multiprocessing.Process(target=one_process,args=(newGP,dist1,dist2))
        p.start()
        PS.append(p)

    for p in PS:
        p.join()

    print state.w_avg_N_s.value
    state.save("xxx2",True)
コード例 #5
0
def test1():
    state = PerceptronSharedState(10000)
    dist1 = DataGen(1000)
    dist2 = DataGen(1000)
    PS = []
    for x in range(8):
        newGP = GPerceptron.from_shared_state(state)
        p = multiprocessing.Process(target=one_process,
                                    args=(newGP, dist1, dist2))
        p.start()
        PS.append(p)

    for p in PS:
        p.join()

    print state.w_avg_N_s.value
    state.save("xxx2", True)
コード例 #6
0
 def __init__(self,
              model_file_name,
              fName=None,
              gp=None,
              beam_size=40,
              test_time=False):
     self.test_time = test_time
     self.features = Features()
     self.beam_size = beam_size
     self.model = Model.load(model_file_name)
     if gp:
         self.perceptron = gp
         return
     elif fName is not None:
         self.perceptron_state = PerceptronSharedState.load(
             fName, retrainable=True)
     else:
         self.perceptron_state = PerceptronSharedState(5000000)
     self.perceptron = GPerceptron.from_shared_state(self.perceptron_state)