当前位置: 首页>>代码示例>>Python>>正文


Python Tester.test方法代码示例

本文整理汇总了Python中tester.Tester.test方法的典型用法代码示例。如果您正苦于以下问题:Python Tester.test方法的具体用法?Python Tester.test怎么用?Python Tester.test使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tester.Tester的用法示例。


在下文中一共展示了Tester.test方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from tester import Tester [as 别名]
# 或者: from tester.Tester import test [as 别名]
def main(config):
    prepare_dirs_and_logger(config)
    save_config(config)

    if config.is_train:
        from trainer import Trainer
        if config.dataset == 'line':
            from data_line import BatchManager
        elif config.dataset == 'ch':
            from data_ch import BatchManager
        elif config.dataset == 'kanji':
            from data_kanji import BatchManager
        elif config.dataset == 'baseball' or\
             config.dataset == 'cat':
            from data_qdraw import BatchManager

        batch_manager = BatchManager(config)
        trainer = Trainer(config, batch_manager)
        trainer.train()
    else:
        from tester import Tester
        if config.dataset == 'line':
            from data_line import BatchManager
        elif config.dataset == 'ch':
            from data_ch import BatchManager
        elif config.dataset == 'kanji':
            from data_kanji import BatchManager
        elif config.dataset == 'baseball' or\
             config.dataset == 'cat':
            from data_qdraw import BatchManager
        
        batch_manager = BatchManager(config)
        tester = Tester(config, batch_manager)
        tester.test()
开发者ID:byungsook,项目名称:vectornet,代码行数:36,代码来源:main.py

示例2: train_and_test

# 需要导入模块: from tester import Tester [as 别名]
# 或者: from tester.Tester import test [as 别名]
def train_and_test(image_loader, feature_extractor):
    """
    Simple implementation of train and test function
    :param image_loader:
    :param feature_extractor:
    """
    first_class_train_data, first_class_test_data = get_train_and_test_data(params.first_class_params)
    second_class_train_data, second_class_test_data = get_train_and_test_data(params.second_class_params)

    train_data = list(first_class_train_data) + list(second_class_train_data)
    random.shuffle(train_data)
    trainer = Trainer(image_loader, feature_extractor)
    solve_container = trainer.train(train_data, params.svm_params)

    test_data = list(first_class_test_data) + list(second_class_test_data)
    tester = Tester(image_loader, solve_container)
    return tester.test(test_data)
开发者ID:ktisha,项目名称:object_class_recognition,代码行数:19,代码来源:main.py

示例3: main

# 需要导入模块: from tester import Tester [as 别名]
# 或者: from tester.Tester import test [as 别名]
def main():
    f = open('try_3.txt','w')
    g = open('accs.txt', 'w')
    g.close()
    task = MarioTask("testbed", initMarioMode = 2)
    task.env.initMarioMode = 2
    task.env.levelDifficulty = 1

    results = [] 
    names = [] 

    
    iterations = 50
    rounds = 15
     
    agent = Supervise(IT,useKMM = False)
    exp = EpisodicExperiment(task, agent) 
    T = Tester(agent,exp)
    sl_data, sup_data, acc = T.test(rounds = rounds, iterations = iterations)

    np.save('./data/sup_data.npy', sup_data)
    np.save('./data/sl_data.npy', sl_data)
    np.save('./data/acc.npy', acc)    
    
    IPython.embed()

    analysis = Analysis()
    analysis.get_perf(sup_data, range(iterations))
    analysis.get_perf(sl_data, range(iterations))
    analysis.plot(names=['Supervisor', 'Supervised Learning'], label='Reward', filename='./results/return_plots.eps')#, ylims=[0, 1600])

    acc_a = Analysis()
    acc_a.get_perf(acc, range(iterations))
    acc_a.plot(names=['Supervised Learning Acc.'], label='Accuracy', filename='./results/acc_plots.eps')

    print "finished"
开发者ID:mdlaskey,项目名称:marioai,代码行数:38,代码来源:testbed_all.py

示例4: main

# 需要导入模块: from tester import Tester [as 别名]
# 或者: from tester.Tester import test [as 别名]
def main():
    f = open('try_3.txt','w')
    g = open('accs.txt', 'w')
    g.close()
    task = MarioTask("testbed", initMarioMode = 2)
    task.env.initMarioMode = 2
    task.env.levelDifficulty = 1

    results = [] 
    names = [] 

    with open('type.txt', 'w') as f:
        f.write('ent')
    
    # # #test dagger
    # iterations = 1
    # rounds = 1
    
    iterations = 50
    rounds = 15
    #agent = Dagger(IT,useKMM = False)
    #exp = EpisodicExperiment(task, agent) 
    #T = Tester(agent,exp)
    #dagger_results = T.test(rounds = rounds,iterations = iterations)
    #dagger_data = dagger_results[-1]
    #dagger_results = dagger_results[:-1]
    #results.append(dagger_results)
    #names.append('dagger')
    #pickle.dump(results,open('results.p','wb'))

    #agent = Dagger(IT, useKMM=False)
    #exp = EpisodicExperiment(task, agent)
    #T = Tester(agent, exp)
    #dagger_data, _, acc = T.test(rounds = rounds, iterations = iterations)
    
    agent = Supervise(IT,useKMM = False)
    exp = EpisodicExperiment(task, agent) 
    T = Tester(agent,exp)
    prefix = 'dt-noisy-sup-change-entropy'
    sl_data, sup_data, acc = T.test(rounds = rounds, iterations = iterations, prefix = prefix)

    np.save('./data/' + prefix + '-sup_data.npy', sup_data)
    np.save('./data/' + prefix + '-sl_data.npy', sl_data)
    np.save('./data/' + prefix + '-acc.npy', acc)    
    
    # IPython.embed()

    analysis = Analysis()
    analysis.get_perf(sup_data, range(iterations))
    analysis.get_perf(sl_data, range(iterations))
    analysis.plot(names=['Supervisor', 'Supervised Learning'], label='Reward', filename='./results/' + prefix + '-return_plots.eps')#, ylims=[0, 1600])

    acc_a = Analysis()
    acc_a.get_perf(acc, range(iterations))
    acc_a.plot(names=['Supervised Learning Acc.'], label='Accuracy', filename='./results/' + prefix + '-acc_plots.eps')

    """


    agent = Dagger(IT,useKMM = False)
    exp = EpisodicExperiment(task, agent) 
    T = Tester(agent,exp)
    dagger_data, _, acc = T.test(rounds = rounds, iterations = iterations)

    np.save('./data/dagger_data.npy', dagger_data)
    np.save('./data/acc.npy', acc)    
    
    IPython.embed()

    analysis = Analysis()
    analysis.get_perf(dagger_data, range(iterations))
    analysis.plot(names=['DAgger'], label='Reward', filename='./results/return_plots.eps')

    acc_a = Analysis()
    acc_a.get_perf(acc, range(iterations))
    acc_a.plot(names=['DAgger Acc.'], label='Accuracy', filename='./results/acc_plots.eps')

    """
    
    #agent = Supervise(IT,useKMM = False)
    #exp = EpisodicExperiment(task, agent) 
    #T = Tester(agent,exp)
    #supervise_results = T.test(rounds = rounds, iterations = iterations)
    #supervise_data = supervise_results[-1]
    #supervise_results = supervise_results[:-1]
    #results.append(supervise_results)
    #names.append('supervise')
    #pickle.dump(results,open('results.p','wb'))

    #IPython.embed()

    #analysis = Analysis()
    #analysis.get_perf(supervise_data, results[1][5])
    #analysis.get_perf(dagger_data, results[0][5])
    #analysis.plot(names=['Supervise', 'DAgger'], label='Reward', filename='./return_plot.eps')#, ylims=[-1, 0])




    # agent = Sheath(IT,useKMM = False,sigma = 1.0)
#.........这里部分代码省略.........
开发者ID:mdlaskey,项目名称:marioai,代码行数:103,代码来源:testbed-dt-noisy-sup-change-entropy.py

示例5: range

# 需要导入模块: from tester import Tester [as 别名]
# 或者: from tester.Tester import test [as 别名]
    analysis.get_perf(sup_data, range(iterations))
    analysis.get_perf(sl_data, range(iterations))
    analysis.plot(names=['Supervisor', 'Supervised Learning'], label='Reward', filename='./results/return_plots.eps')#, ylims=[0, 1600])

    acc_a = Analysis()
    acc_a.get_perf(acc, range(iterations))
    acc_a.plot(names=['Supervised Learning Acc.'], label='Accuracy', filename='./results/acc_plots.eps')

    """


    agent = Dagger(IT,useKMM = False)
    exp = EpisodicExperiment(task, agent) 
    T = Tester(agent,exp)
    prefix = 'svc-dagger-change'
    dagger_data, _, acc = T.test(rounds = rounds, iterations = iterations, prefix = prefix)

    np.save('./data/svc-dagger-change-dagger_data.npy', dagger_data)
    np.save('./data/svc-dagger-change-acc.npy', acc)    
    
    # IPython.embed()

    analysis = Analysis()
    analysis.get_perf(dagger_data, range(iterations))
    analysis.plot(names=['DAgger'], label='Reward', filename='./results/svc-dagger-change-return_plots.eps')

    acc_a = Analysis()
    acc_a.get_perf(acc, range(iterations))
    acc_a.plot(names=['DAgger Acc.'], label='Accuracy', filename='./results/svc-dagger-change-acc_plots.eps')

    
开发者ID:mdlaskey,项目名称:marioai,代码行数:31,代码来源:testbed-svc-dagger-change.py

示例6: main

# 需要导入模块: from tester import Tester [as 别名]
# 或者: from tester.Tester import test [as 别名]
def main():
    f = open('try_3.txt','w')
    g = open('accs.txt', 'w')
    g.close()
    task = MarioTask("testbed", initMarioMode = 2)
    task.env.initMarioMode = 2
    task.env.levelDifficulty = 1

    results = [] 
    names = [] 
    
    with open('type.txt', 'w') as f:
        f.write('dt')
    
    iterations = 20
    rounds = 30
    learning_samples = 33
    eval_samples = 10

    # iterations = 5
    # rounds = 2
    # learning_samples = 3
    # eval_samples = 2

    agent = Dagger(IT,useKMM = False)

    if args['linear']:
        agent.learner.linear = True
        prefix = 'svc-dagger-change-'
    else:
        agent.learner.linear = False
        prefix = 'dt-dagger-change-'

    exp = EpisodicExperiment(task, agent) 
    T = Tester(agent,exp)
    dagger_data, _, acc, loss, js, test_acc = T.test(rounds = rounds, iterations = iterations,
         learning_samples = learning_samples, eval_samples = eval_samples, prefix = prefix)

    np.save('./data/' + prefix + 'dagger_data.npy', dagger_data)
    np.save('./data/' + prefix + 'acc.npy', acc)    
    np.save('./data/' + prefix + 'loss.npy', loss)
    np.save('./data/' + prefix + 'js.npy', js)
    np.save('./data/' + prefix + 'test_acc.npy', test_acc)
    
    analysis = Analysis()
    analysis.get_perf(dagger_data, range(iterations))
    analysis.plot(names=['DAgger'], label='Reward', filename='./results/' + prefix + 'return_plots.eps')

    acc_a = Analysis()
    acc_a.get_perf(acc, range(iterations))
    acc_a.plot(names=['DAgger Acc.'], label='Accuracy', filename='./results/' + prefix + 'acc_plots.eps', ylims=[0,1])

    test_acc_a = Analysis()
    test_acc_a.get_perf(test_acc, range(iterations))
    test_acc_a.plot(names=['DAgger Acc.'], label='Test Accuracy', filename='./results/' + prefix + 'test_acc_plots.eps', ylims=[0, 1])

    loss_a = Analysis()
    loss_a.get_perf(loss, range(iterations))
    loss_a.plot(names=['DAgger Loss'], label='Loss', filename='./results/' + prefix + 'loss_plots.eps', ylims=[0, 1])

    js_a = Analysis()
    js_a.get_perf(js, range(iterations))
    js_a.plot(names=['DAgger'], label='J()', filename='./results/' + prefix + '-js_plots.eps')

    
    print "finished"
开发者ID:mdlaskey,项目名称:marioai,代码行数:68,代码来源:testbed-dt-dagger-change.py

示例7: Tester

# 需要导入模块: from tester import Tester [as 别名]
# 或者: from tester.Tester import test [as 别名]
import subprocess
import sys
sys.path.insert(0, "../")
from tester import Tester
t = Tester()
##

from task import getCombinationsCount, getMinimalCombinationsCount

## write tests here --

# part 1

t.test("nothing to divide", getCombinationsCount(0, [1, 2, 3]), 1)
t.test("too small bottle", getCombinationsCount(10, [5]), 0)
t.test("one large enough bottle", getCombinationsCount(10, [10]), 1)
t.test("two bottles", getCombinationsCount(2, [2, 2]), 2)
t.test("two bottles, one too small", getCombinationsCount(2, [2, 1]), 1)
t.test("two small bottles", getCombinationsCount(2, [1, 1]), 1)

# part 2

t.test("", getMinimalCombinationsCount(10, [5, 5, 5, 10]), 1)

## -- end of tests

def askYesNo(question):
	print(question + " [y/n]")
	yes = set(['yes','y', 'ye', ''])
	no = set(['no','n'])	
	while True:
开发者ID:simonrozsival,项目名称:advent-of-code,代码行数:33,代码来源:test.py

示例8: buildStructure

# 需要导入模块: from tester import Tester [as 别名]
# 或者: from tester.Tester import test [as 别名]
    ("A", "C", 12),
    ("C", "A", -3),
    ("B", "C", 6),
    ("C", "B", -1),
    ("A", "D", 0),
    ("B", "D", 9),
    ("C", "D", -14),
    ("D", "A", -100),
    ("D", "B", 23),
    ("D", "C", 14),
]
structure = buildStructure(happinessDeclaration)

t.test(
    "David would lose 53 happiness units by sitting next to Carol.",
    parseLine("David would lose 53 happiness units by sitting next to Carol."),
    ("David", "Carol", -53),
)
t.test(
    "David would gain 43 happiness units by sitting next to Alice.",
    parseLine("David would gain 43 happiness units by sitting next to Alice."),
    ("David", "Alice", 43),
)
t.test(
    "generate permutations",
    generatePermutations(["a", "b", "c"]),
    [["a", "b", "c"], ["a", "c", "b"], ["b", "a", "c"], ["b", "c", "a"], ["c", "a", "b"], ["c", "b", "a"]],
)
t.test(
    "build data structure",
    structure,
开发者ID:simonrozsival,项目名称:advent-of-code,代码行数:33,代码来源:test.py


注:本文中的tester.Tester.test方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。