本文整理匯總了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()
示例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)
示例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"
示例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)
#.........這裏部分代碼省略.........
示例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')
示例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"
示例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:
示例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,