亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? learner.py

?? The library is a C++/Python implementation of the variational building block framework introduced in
?? PY
字號:
# -*- coding: iso-8859-1 -*-## This file is a part of the Bayes Blocks library## Copyright (C) 2001-2006 Markus Harva, Antti Honkela, Alexander# Ilin, Tapani Raiko, Harri Valpola and Tomas 謘tman.## This program is free software; you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by# the Free Software Foundation; either version 2, or (at your option)# any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the# GNU General Public License (included in file License.txt in the# program package) for more details.## $Id: Learner.py 5 2006-10-26 09:44:54Z ah $#import Helpersimport timeimport signalsigintencountered = 0def siginthandler(signum, frame):    global sigintencountered    sigintencountered = 1SIGNORE = -1SSTOP = 0SRAISE = 1class timewrap:    def __init__(self):        self.lastclock = time.clock()        self.wraps = 0    def clock(self):        newtime = time.clock()        if self.lastclock > newtime:            self.wraps += 1        self.lastclock = newtime        # math.exp(32*math.log(2)-6*math.log(10)) == 4294.9672959999916        return newtime + self.wraps*4294.9672959999916class Learner:    def __getstate__(self):        odict = self.__dict__.copy()        del odict['costfun']        odict['costfunname'] = self.costfun.im_func.func_name        odict['costfunself'] = self.costfun.im_self        return odict    def __setstate__(self, dict):        if dict.has_key('costfunname') and dict.has_key('costfunself'):            costfun = eval("dict['costfunself']" + "." + dict['costfunname'])            del dict['costfunname']            del dict['costfunself']            self.__dict__.update(dict)             self.costfun = costfun        else:            self.__dict__.update(dict)             self.costfun = self.net.Cost    def __init__(self, net, prunefunc=None):        self.net = net        self.printhooke = 1        self.prunefunc = prunefunc        self.history = []        self.benchmark = []        self.iter = 0        self.time = timewrap()        self.functions = {}        self.function_timings = []        self.calls = []        self.costfun = self.net.Cost        self.stopnow = False    def AddFunction(self, name, func, timing):        if not Helpers.IsSequence(timing):            timing = (timing, 0)        self.function_timings.append((timing, name))        self.functions[name] = func        def AddCall(self, name, func, iter):        if not Helpers.IsSequence(iter):            iter = (iter,)        for i in iter:            assert isinstance(i, int)            self.calls.append((i, name, func))    def SortCalls(self):        """Sorts self.calls only using first item in each tuple."""        self.calls.sort(lambda a, b: cmp(a[0], b[0]))                def CallFunc(self, func, name=None, verbose=0):        if callable(func):            val = func()        elif len(func) == 1:            val = func[0]()        elif len(func) == 2:            val = func[0](*func[1])        elif len(func) == 3:            val = func[0](*func[1], **func[2])        else:            raise ValueError, "len(func) is not in (1,2,3)"        if (name is not None) and val:            self.HistoryAdd(name, val)            if verbose:                print name+":", val    def HistoryAdd(self, record, data = ()):        if type(data) == type(()):            self.history.append((record, self.iter, self.costfun())+data)        else:            self.history.append((record, self.iter, self.costfun(), data))    def TryPruning(self, *args, **kws):        pruningout = apply(self.prunefunc, (self.net,) + args, kws)        self.HistoryAdd("Pruning", pruningout)        return pruningout    def HookeJeeves(self):        tmp = self.time.clock()        hookeout = self.net.UpdateAllHookeJeeves(            exploresteps=self.exploresteps, returncost = 1)        timeused = self.time.clock()-tmp        self.benchmark.append(timeused)        self.HistoryAdd("HookeJeeves",                        (timeused, self.time.clock()) +  hookeout)        if self.printhooke:            print self.iter, ":", hookeout        self.iter += 1        return hookeout        def Iteration(self, debug = 0):        tmp = self.time.clock()        if debug:            self.net.UpdateAllDebug()        else:            self.net.UpdateAll()        timeused = self.time.clock()-tmp        self.benchmark.append(timeused)        self.HistoryAdd("Iteration", (timeused, self.time.clock()))        self.iter += 1    def CheckDoHooke(self, hooke):        if hooke:            if isinstance(hooke, int):                if self.iter%hooke == hooke/2:                    return 1            elif isinstance(hooke, list):                if len(hooke) and hooke[-1] >= self.iter:                    del hooke[-1]                    return 1            elif callable(hooke):                return hooke(self.iter)            else:                raise TypeError, "Bad type for hooke parameter"        return 0    def LearnNet(self, printcost=0, iters=200,                 hooke=None, exploresteps=1, printhooke=None, raisekbd=SSTOP,                 debug=0, verbosecall=1):        """Learns the net.        Parameters:        printcost=0 - If nonzero causes printing of cost every printcost                      iterations.        iters=200 - Number of iteration where to stop (numbering starts                    where LearnNet() last time stopped).        hooke=None  - integer, list or function                   if None (or not given) use self.usehooke                   if integer != 0, then Hooke-Jeeves is performed when                   iter%hooke==hooke/2                   if list Hooke-Jeeves is performed if (iter in hooke)                   if function HookeJeeves is performde if funciton(iter)        exploresteps=4 - Sent as parameter to UpdateAllHookeJeeves()        """        self.stopnow = False        if debug:            self.costfun = self.net.CostDebug        else:            self.costfun = self.net.Cost        if iters < 0:            iters = self.iter - iters        self.exploresteps=exploresteps        if printhooke is not None:            self.printhooke = printhooke        else:            if printcost == 0:                self.printhooke = 0            else:                self.printhooke = 1        if raisekbd != SIGNORE:            global sigintencountered            sigintencountered = 0            oldsiginthandler = signal.signal(signal.SIGINT, siginthandler)        if printcost:            print self.iter, ":", self.costfun()        if type(hooke) == type([]):            hooke = hooke[:]            hooke.sort()            hooke.reverse()            #TODO some better find algorithm            while len(hooke) and hooke[-1] < iter:                del hooke[-1]        self.SortCalls()        while self.iter < iters:            if (raisekbd != SIGNORE) and sigintencountered:                print "Learning stopped with ctrl-C"                sigintencountered = 0                if raisekbd == SSTOP:                    return 1                else:                    raise KeyboardInterrupt            if self.CheckDoHooke(hooke):                self.HookeJeeves()            else:                self.Iteration(debug)            while len(self.calls) > 0 and self.calls[0][0] == self.iter:                self.CallFunc(self.calls[0][2],                              self.calls[0][1],                              verbose=verbosecall)                del self.calls[0]            for t in self.function_timings:                if (self.iter%t[0][0] == t[0][1]):                    self.CallFunc(self.functions[t[1]], t[1])            if printcost and (self.iter%printcost == 0):                if debug:                    debugstring = "(debug) "                else:                    debugstring = ""                print "%s%d : %f" % (debugstring, self.iter, self.costfun())            if self.stopnow:                break        if raisekbd != SIGNORE:            signal.signal(signal.SIGINT, oldsiginthandler)            if sigintencountered:                print "Learning ready when ctrl-C was sent"                sigintencountered = 0                if raisekbd:                    raise KeyboardInterrupt        return 0class LearnerOL(Learner):    def __init__(self, net, stepperfunc, stepperargs=(), epsilon=1e-2):        self.net = net        self.history = []        self.benchmark = []        self.timestep = 0        self.iter = 0        self.time = timewrap()        self.epsilon = epsilon        self.stepperfunc = stepperfunc        self.stepperargs = stepperargs        self.functions = {}        self.function_timings = []    def HistoryAdd(self, record, data = ()):        if type(data) == type(()):            self.history.append(                (record, self.timestep, self.iter, self.net.Cost())+data)        else:            self.history.append(                (record, self.timestep, self.iter, self.net.Cost(), data))    def PrintCost(self):        print `self.timestep` + "(" + `self.iter` + "):", self.net.Cost()        def Iteration(self, printiters = 0):        self.net.UpdateTimeDep()        if printiters and (self.iter%printiters == 0):            self.PrintCost()        self.iter += 1    def StepTime(self, printsteps = 1):        self.net.UpdateTimeInd()        if printsteps and (self.timestep%printsteps == 0):            self.PrintCost()        self.iter = 0        self.timestep += 1        self.stepperfunc(*self.stepperargs)    def DoTimeStep(self, printiters = 0, printsteps = 1):        oldcost = 1e300        cost = self.net.Cost()        while (oldcost - cost) > self.epsilon:            self.Iteration(printiters = printiters)            oldcost = cost            cost = self.net.Cost()        self.StepTime(printsteps = printsteps)    def LearnNet(self, stopstep, printiters = 0, printsteps = 1,                 raisekbd = SSTOP):        if stopstep < 0:            stopstep = self.timestep - stopstep        if raisekbd not in (SIGNORE,SSTOP,SRAISE):            raise ValueError, "Unkown raisekbd value"        if raisekbd != SIGNORE:            global sigintencountered            sigintencountered = 0            oldsiginthandler = signal.signal(signal.SIGINT, siginthandler)        while self.timestep < stopstep:            if (raisekbd != SIGNORE) and sigintencountered:                print "Learning stopped with ctrl-C"                sigintencountered = 0                if raisekbd == SSTOP:                    return 1                elif raisekbd == SRAISE:                    raise KeyboardInterrupt                else:                    assert(0)            self.DoTimeStep(printiters = printiters, printsteps = printsteps)            for t in self.function_timings:                if (self.timestep%t[0][0] == t[0][1]):                    self.CallFunc(self.functions[t[1]], t[1])        if raisekbd != SIGNORE:            signal.signal(signal.SIGINT, oldsiginthandler)            if sigintencountered:                print "Learning ready when ctrl-C was sent"                sigintencountered = 0                if raisekbd == SRAISE:                    raise KeyboardInterrupt

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
中文字幕一区二区在线观看 | 亚洲激情自拍偷拍| 精品区一区二区| 日韩不卡在线观看日韩不卡视频| 亚洲男人的天堂在线aⅴ视频| 国产精品人妖ts系列视频| 2014亚洲片线观看视频免费| 精品国产乱码久久久久久蜜臀| 欧美va亚洲va| 久久久99久久| 国产精品久久久久久久久动漫| 中文字幕一区免费在线观看| 亚洲欧美日韩电影| 亚洲.国产.中文慕字在线| 午夜精品一区二区三区电影天堂 | 亚洲成人免费看| 图片区小说区国产精品视频| 日韩精品久久久久久| 久久99精品久久久| 国产1区2区3区精品美女| 亚洲人成网站影音先锋播放| 国产一区二区三区免费在线观看| 久久精品国产成人一区二区三区| 国产精品一二三在| 91视频.com| 欧美一级日韩免费不卡| 久久久91精品国产一区二区三区| 国产精品色噜噜| 亚洲精品国久久99热| 奇米777欧美一区二区| 国产精品一级二级三级| 日本韩国欧美在线| 精品欧美久久久| 伊人开心综合网| 毛片不卡一区二区| 99re这里只有精品首页| 欧美一级搡bbbb搡bbbb| 中文字幕一区二| 蜜桃视频在线观看一区| av在线一区二区| 日韩久久免费av| 亚洲美女免费视频| 精品在线播放免费| 欧美午夜片在线看| 久久久久久久免费视频了| 亚洲自拍偷拍综合| 丁香婷婷综合色啪| 欧美一区二区在线免费播放| 亚洲日本在线a| 国产美女在线精品| 91精品国产入口在线| 一区二区三区四区乱视频| 国产一区二区三区四区五区美女 | 日韩免费看网站| 亚洲六月丁香色婷婷综合久久 | 欧美伦理视频网站| 国产精品久久久久精k8| 国内精品嫩模私拍在线| 欧美日韩国产精品成人| 亚洲日本护士毛茸茸| 国产乱子伦视频一区二区三区| 欧美电影在哪看比较好| 一区二区三区四区不卡视频| 国产91在线观看丝袜| 久久综合色8888| 欧美第一区第二区| 2020国产精品自拍| 国产精品一区专区| 精品欧美乱码久久久久久1区2区| 亚洲成a人v欧美综合天堂下载| 99久久国产免费看| 国产精品沙发午睡系列990531| 久久69国产一区二区蜜臀| 91精品国产综合久久久久久久久久| 亚洲另类中文字| 欧美在线看片a免费观看| 亚洲免费观看高清完整版在线 | www.综合网.com| 国产色婷婷亚洲99精品小说| 免费人成黄页网站在线一区二区 | 奇米色一区二区三区四区| 欧美午夜片在线看| 亚洲成人av福利| 在线播放国产精品二区一二区四区 | 一本色道久久综合亚洲精品按摩| 裸体一区二区三区| 精品久久人人做人人爰| 激情五月婷婷综合| 国产欧美日韩在线| 99精品国产热久久91蜜凸| 亚洲人成人一区二区在线观看| 色综合天天视频在线观看| 亚洲综合成人在线| 日韩无一区二区| 国产福利精品一区二区| 日韩美女久久久| 欧美日韩一区二区三区四区五区| 欧美肥大bbwbbw高潮| 日韩av午夜在线观看| 精品国产成人系列| 不卡电影一区二区三区| 一区二区三区在线免费| 欧美一级免费大片| 国产精品一区二区在线播放| 亚洲视频在线一区二区| 日本最新不卡在线| 欧美激情艳妇裸体舞| 色94色欧美sute亚洲13| 免费观看一级欧美片| 国产日韩av一区二区| 在线欧美一区二区| 国产一区二区在线影院| 一区二区三区在线免费视频 | 久久99国产精品麻豆| 国产亚洲欧洲一区高清在线观看| 91一区二区三区在线播放| 日产精品久久久久久久性色| 中文乱码免费一区二区 | 91精品国产91久久久久久最新毛片| 国产伦精品一区二区三区视频青涩| 国产精品久久午夜夜伦鲁鲁| 欧美福利电影网| 色综合亚洲欧洲| 国产一区二区三区不卡在线观看| 亚洲人成网站在线| 精品国产a毛片| 亚洲va中文字幕| 国产精品人成在线观看免费| 7777精品伊人久久久大香线蕉完整版 | 久久久亚洲国产美女国产盗摄| 99热精品国产| 国产精品一区二区黑丝| 6080午夜不卡| 91国偷自产一区二区三区成为亚洲经典 | 成人免费视频视频| 美腿丝袜亚洲一区| 亚洲国产另类av| 91麻豆国产自产在线观看| 国产九色精品成人porny| 日韩国产在线观看| 亚洲超丰满肉感bbw| 综合分类小说区另类春色亚洲小说欧美| 日韩精品中文字幕在线一区| 欧美高清性hdvideosex| 中文字幕一区不卡| 中文字幕精品一区二区精品绿巨人 | 亚洲精品成人少妇| 亚洲欧美影音先锋| 国产精品麻豆一区二区| 国产日韩欧美精品在线| 精品免费日韩av| 精品国产免费人成在线观看| 日韩三级中文字幕| 69堂精品视频| 日韩视频国产视频| 精品国产青草久久久久福利| 精品国产乱子伦一区| 欧美精品一区在线观看| 久久一区二区三区四区| 26uuu国产日韩综合| 久久久国产精品麻豆| 久久久久久久综合| 国产精品久久综合| 亚洲卡通动漫在线| 色婷婷av一区二区三区大白胸| 91蜜桃婷婷狠狠久久综合9色| 99久久久国产精品| 欧美揉bbbbb揉bbbbb| 欧美精品一卡两卡| 欧美va日韩va| 亚洲国产精品ⅴa在线观看| |精品福利一区二区三区| 一区二区三区四区视频精品免费| 亚洲二区在线视频| 麻豆精品一区二区av白丝在线| 国内精品国产成人国产三级粉色| 国产成人综合在线观看| 99久久精品国产麻豆演员表| 欧美综合一区二区| 日韩欧美一级二级三级 | 国产成人av电影在线| 成人激情图片网| 欧美视频一区二区三区在线观看| 9191久久久久久久久久久| 26uuu国产在线精品一区二区| 综合久久久久综合| 三级欧美在线一区| 国产成人午夜片在线观看高清观看| av激情成人网| 91精品在线观看入口| 欧美激情一区在线观看| 亚洲成av人在线观看| 丁香亚洲综合激情啪啪综合| 欧美日韩在线直播| 中文字幕欧美日韩一区| 日韩精品一二三区| 91在线丨porny丨国产| 日韩三级视频在线看| 亚洲欧洲色图综合| 精品在线免费观看|