本文整理汇总了Python中test.test方法的典型用法代码示例。如果您正苦于以下问题:Python test.test方法的具体用法?Python test.test怎么用?Python test.test使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类test
的用法示例。
在下文中一共展示了test.test方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: prune_and_eval
# 需要导入模块: import test [as 别名]
# 或者: from test import test [as 别名]
def prune_and_eval(model, sorted_bn, percent=.0):
model_copy = deepcopy(model)
thre_index = int(len(sorted_bn) * percent)
thre = sorted_bn[thre_index]
print(f'Gamma value that less than {thre:.4f} are set to zero!')
remain_num = 0
for idx in prune_idx:
bn_module = model_copy.module_list[idx][1]
mask = obtain_bn_mask(bn_module, thre)
remain_num += int(mask.sum())
bn_module.weight.data.mul_(mask)
print("let's test the current model!")
mAP = eval_model(model_copy)[0][2]
print(f'Number of channels has been reduced from {len(sorted_bn)} to {remain_num}')
print(f'Prune ratio: {1-remain_num/len(sorted_bn):.3f}')
print(f"mAP of the 'pruned' model is {mAP:.4f}")
return thre
示例2: main
# 需要导入模块: import test [as 别名]
# 或者: from test import test [as 别名]
def main():
args = get_args()
create_link(args.dataset_dir)
str_ids = args.gpu_ids.split(',')
args.gpu_ids = []
for str_id in str_ids:
id = int(str_id)
if id >= 0:
args.gpu_ids.append(id)
print(not args.no_dropout)
if args.training:
print("Training")
model = md.cycleGAN(args)
model.train(args)
if args.testing:
print("Testing")
tst.test(args)
示例3: evaluate
# 需要导入模块: import test [as 别名]
# 或者: from test import test [as 别名]
def evaluate():
# Clear stats
stats.clearStats(True)
# Parse Dataset
cfg.CLASSES, TRAIN, VAL = train.parseDataset()
# Build Model
NET = birdnet.build_model()
# Train and return best net
best_net = train.train(NET, TRAIN, VAL)
# Load trained net
SNAPSHOT = io.loadModel(best_net)
# Test snapshot
MLRAP, TIME_PER_EPOCH = test.test(SNAPSHOT)
result = np.array([[MLRAP]], dtype='float32')
return result
示例4: Test10
# 需要导入模块: import test [as 别名]
# 或者: from test import test [as 别名]
def Test10():
input_str = '''
APPEND FROM TABLE_NAME
APPEND FROM TABLE_NAME TYPE DELIMITED
APPEND FROM \'table\' + \'_\' + \'name\' TYPE \'Delimited\'
APPEND FROM ARRAY TEST
'''.strip()
output_str = '''
DB.append_from(None, \'table_name\')
DB.append_from(None, \'table_name\', filetype=\'delimited\')
DB.append_from(None, \'table_name\', filetype=\'delimited\')
DB.insert(None, S.test)
'''.strip()
test_output_str = vfp2py.vfp2py.prg2py(input_str, 'cp1252', parser_start='lines', prepend_data='').strip()
try:
assert test_output_str == output_str
except AssertionError:
diff = difflib.unified_diff((test_output_str + '\n').splitlines(1), (output_str + '\n').splitlines(1))
print(''.join(diff))
raise
示例5: Test13
# 需要导入模块: import test [as 别名]
# 或者: from test import test [as 别名]
def Test13():
input_str = '''
PUBLIC ARRAY somearray[2, 5]
public array def[10]
SOMEARRAY(1, 4) = 3
PRIVATE TEST, somearray[2, 5]
EXTERNAL ARRAY someotherarray[3]
EXTERNAL PROCEDURE test
'''.strip()
output_str = '''
M.add_public(somearray=Array(2, 5))
M.add_public(**{\'def\': Array(10)})
S.somearray[1, 4] = 3
M.add_private(\'test\', somearray=Array(2, 5))
# FIX ME: EXTERNAL ARRAY someotherarray[3]
# FIX ME: EXTERNAL PROCEDURE test
'''.strip()
test_output_str = vfp2py.vfp2py.prg2py(input_str, 'cp1252', parser_start='lines', prepend_data='').strip()
try:
assert test_output_str == output_str
except AssertionError:
diff = difflib.unified_diff((test_output_str + '\n').splitlines(1), (output_str + '\n').splitlines(1))
print(''.join(diff))
raise
示例6: Test16
# 需要导入模块: import test [as 别名]
# 或者: from test import test [as 别名]
def Test16():
input_str = '''
SKIP
SKIP 10
SKIP IN TEST
SKIP someval IN TEST
'''.strip()
output_str = '''
DB.skip(None, 1)
DB.skip(None, 10)
DB.skip(\'test\', 1)
DB.skip(\'test\', S.someval)
'''.strip()
test_output_str = vfp2py.vfp2py.prg2py(input_str, 'cp1252', parser_start='lines', prepend_data='').strip()
try:
assert test_output_str == output_str
except AssertionError:
diff = difflib.unified_diff((test_output_str + '\n').splitlines(1), (output_str + '\n').splitlines(1))
print(''.join(diff))
raise
示例7: Test19
# 需要导入模块: import test [as 别名]
# 或者: from test import test [as 别名]
def Test19():
input_str = '''
scatter name test
scatter blank memvar
scatter to somearray
gather name test
gather memvar
gather from somearray
'''.strip()
output_str = '''
S.test = vfpfunc.scatter(totype=\'name\')
vfpfunc.scatter(blank=True)
S.somearray = vfpfunc.scatter(totype=\'array\')
vfpfunc.gather(val=S.test)
vfpfunc.gather()
vfpfunc.gather(val=S.somearray)
'''.strip()
test_output_str = vfp2py.vfp2py.prg2py(input_str, 'cp1252', parser_start='lines', prepend_data='').strip()
try:
assert test_output_str == output_str
except AssertionError:
diff = difflib.unified_diff((test_output_str + '\n').splitlines(1), (output_str + '\n').splitlines(1))
print(''.join(diff))
raise
示例8: Test20
# 需要导入模块: import test [as 别名]
# 或者: from test import test [as 别名]
def Test20():
input_str = '''
REPORT FORM TEST.FRX TO PRINTER NOCONSOLE
REPORT FORM ?
'''.strip()
output_str = '''
vfpfunc.report_form(\'test.frx\')
vfpfunc.report_form(None)
'''.strip()
test_output_str = vfp2py.vfp2py.prg2py(input_str, 'cp1252', parser_start='lines', prepend_data='').strip()
try:
assert test_output_str == output_str
except AssertionError:
diff = difflib.unified_diff((test_output_str + '\n').splitlines(1), (output_str + '\n').splitlines(1))
print(''.join(diff))
raise
示例9: parse
# 需要导入模块: import test [as 别名]
# 或者: from test import test [as 别名]
def parse():
parser = argparse.ArgumentParser(description="MLDS&ADL HW3")
parser.add_argument('--env_name', default=None, help='environment name')
parser.add_argument('--train_pg', action='store_true', help='whether train policy gradient')
parser.add_argument('--test_pg', action='store_true', help='whether test policy gradient')
parser.add_argument('--train_ac', action='store_true', help='wheher train Actor Critic')
parser.add_argument('--train_pgc', action='store_true', help='wheher train PG on cart')
parser.add_argument('--video_dir', default=None, help='output video directory')
parser.add_argument('--do_render', action='store_true', help='whether render environment')
parser.add_argument('--save_summary_path', type=str, default = "pg_summary/", help='')
parser.add_argument('--save_network_path', type=str, default = "saved_pg_networks/", help='')
try:
from argument import add_arguments
parser = add_arguments(parser)
except:
pass
args = parser.parse_args()
return args
示例10: run
# 需要导入模块: import test [as 别名]
# 或者: from test import test [as 别名]
def run(self):
if test is not None and test.test is not None:
assert test.test() == True, "Automated tests failed!"
print("notice all tests passed: OK!")
else:
print("notice automated tests skipped!")
build.run(self)
示例11: Test4
# 需要导入模块: import test [as 别名]
# 或者: from test import test [as 别名]
def Test4():
input_str = '''
LOCAL test
copy file (test) to tset
rename (test) to tset
mkdir test - test
MD test+test
rmdir (test+test)
rd alltrim(test)
!ls -al &pathname
'''.strip()
output_str = '''
M.add_local(\'test\')
shutil.copyfile(S.test, \'tset\')
shutil.move(S.test, \'tset\')
os.mkdir(S.test - S.test)
os.mkdir(\'test+test\')
os.rmdir(S.test + S.test)
os.rmdir(S.test.strip())
vfpfunc.macro_eval(\'!ls -al &pathname\')
'''.strip()
test_output_str = vfp2py.vfp2py.prg2py(input_str, 'cp1252', parser_start='lines', prepend_data='').strip()
try:
assert test_output_str == output_str
except AssertionError:
diff = difflib.unified_diff((test_output_str + '\n').splitlines(1), (output_str + '\n').splitlines(1))
print(''.join(diff))
raise
示例12: Test5
# 需要导入模块: import test [as 别名]
# 或者: from test import test [as 别名]
def Test5():
input_str = '''
CREAT CURSO TEST_CURSOR (SOMEFIELD N(3))
continue
LOCAL SEARCH_FOR, COUNTVAL, SUMVAL
SEARCH_FOR = \'PAUL\'
SEEK ALLTRIM(SEARCH_FOR)
COUNT FOR TEST = 3 TO COUNTVAL
SUM T * T FOR T > 0 TO SUMVAL
LOCATE WHILE X > 5 NOOPTIMIZE
RELEASE SEARCH_FOR, COUNTVAL, SUMVAL
update test set a=b, c=d, e=f where x=3
'''.strip()
output_str = '''
DB.create_cursor(\'test_cursor\', \'somefield n(3)\', \'\')
DB.continue_locate()
M.add_local(\'search_for\', \'countval\', \'sumval\')
S.search_for = \'PAUL\'
DB.seek(None, S.search_for.strip())
S.countval = DB.count(None, (\'all\',), for_cond=lambda: S.test == 3)
S.sumval = DB.sum(None, (\'all\',), lambda: S.t * S.t, for_cond=lambda: S.t > 0)
DB.locate(nooptimize=True, while_cond=lambda: S.x > 5)
del M.search_for, M.countval, M.sumval
DB.update(\'test\', [(\'a\', S.b), (\'c\', S.d), (\'e\', S.f)], where=lambda: S.x == 3)
'''.strip()
test_output_str = vfp2py.vfp2py.prg2py(input_str, 'cp1252', parser_start='lines', prepend_data='').strip()
try:
assert test_output_str == output_str
except AssertionError:
diff = difflib.unified_diff((test_output_str + '\n').splitlines(1), (output_str + '\n').splitlines(1))
print(''.join(diff))
raise
示例13: Test6
# 需要导入模块: import test [as 别名]
# 或者: from test import test [as 别名]
def Test6():
input_str = '''
MKDIR TEST
?DATE()
?PI()
'''.strip()
output_str = '''
from __future__ import division, print_function
import datetime as dt
import math
import os
from vfp2py import vfpfunc
from vfp2py.vfpfunc import DB, Array, C, F, M, S, lparameters, parameters, vfpclass
@lparameters()
def MAIN():
os.mkdir(\'test\')
print(dt.datetime.now().date())
print(math.pi)
'''.strip()
test_output_str = vfp2py.vfp2py.prg2py(input_str, 'cp1252').strip()
try:
assert test_output_str == output_str
except AssertionError:
diff = difflib.unified_diff((test_output_str + '\n').splitlines(1), (output_str + '\n').splitlines(1))
print(''.join(diff))
raise
示例14: Test12
# 需要导入模块: import test [as 别名]
# 或者: from test import test [as 别名]
def Test12():
input_str = '''
LOCAL ARRAY somearray[2, 5]
LOCAL pytuple, pylist, pydict
pytuple = createobject(\'pythontuple\', \'a\', 3, .T.)
pylist = createobject(\'pythonlist\', @somearray)
pylist.callmethod(\'append\', createobject(\'pythontuple\', \'appended value\'))
pydict = createobject(\'pythondictionary\')
pydict.setitem(\'one\', 1)
?pydict.getitem(\'one\')
pythonfunctioncall(\'test\', \'test\', pytuple)
'''.strip()
output_str = '''
M.add_local(somearray=Array(2, 5))
M.add_local(\'pytuple\', \'pylist\', \'pydict\')
S.pytuple = (\'a\', 3, True)
S.pylist = S.somearray.data[:]
S.pylist.append(\'appended value\')
S.pydict = {}
S.pydict[\'one\'] = 1
print(S.pydict[\'one\'])
test.test(*S.pytuple)
'''.strip()
test_output_str = vfp2py.vfp2py.prg2py(input_str, 'cp1252', parser_start='lines', prepend_data='').strip()
try:
assert test_output_str == output_str
except AssertionError:
diff = difflib.unified_diff((test_output_str + '\n').splitlines(1), (output_str + '\n').splitlines(1))
print(''.join(diff))
raise
示例15: prune_and_eval
# 需要导入模块: import test [as 别名]
# 或者: from test import test [as 别名]
def prune_and_eval(model, sorted_bn, percent=.0):
model_copy = deepcopy(model)
thre_index = int(len(sorted_bn) * percent)
thre = sorted_bn[thre_index]
print(f'Gamma value that less than {thre:.4f} are set to zero!')
remain_num = 0
for idx in prune_idx:
bn_module = model_copy.module_list[idx][1]
mask = obtain_bn_mask(bn_module, thre)
remain_num += int(mask.sum())
bn_module.weight.data.mul_(mask)
print("let's test the current model!")
with torch.no_grad():
mAP = eval_model(model_copy)[0][2]
print(f'Number of channels has been reduced from {len(sorted_bn)} to {remain_num}')
print(f'Prune ratio: {1-remain_num/len(sorted_bn):.3f}')
print(f"mAP of the 'pruned' model is {mAP:.4f}")
return thre