本文整理汇总了Python中keras.utils.OrderedEnqueuer.get方法的典型用法代码示例。如果您正苦于以下问题:Python OrderedEnqueuer.get方法的具体用法?Python OrderedEnqueuer.get怎么用?Python OrderedEnqueuer.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类keras.utils.OrderedEnqueuer
的用法示例。
在下文中一共展示了OrderedEnqueuer.get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_context_switch
# 需要导入模块: from keras.utils import OrderedEnqueuer [as 别名]
# 或者: from keras.utils.OrderedEnqueuer import get [as 别名]
def test_context_switch():
enqueuer = OrderedEnqueuer(DummySequence([3, 200, 200, 3]), use_multiprocessing=True)
enqueuer2 = OrderedEnqueuer(DummySequence([3, 200, 200, 3], value=15), use_multiprocessing=True)
enqueuer.start(3, 10)
enqueuer2.start(3, 10)
gen_output = enqueuer.get()
gen_output2 = enqueuer2.get()
acc = []
for i in range(100):
acc.append(next(gen_output)[0, 0, 0, 0])
assert acc[-1] == 99
# One epoch is completed so enqueuer will switch the Sequence
acc = []
for i in range(100):
acc.append(next(gen_output2)[0, 0, 0, 0])
assert acc[-1] == 99 * 15
# One epoch has been completed so enqueuer2 will switch
# Be sure that both Sequence were updated
assert next(gen_output)[0, 0, 0, 0] == 0
assert next(gen_output)[0, 0, 0, 0] == 5
assert next(gen_output2)[0, 0, 0, 0] == 0
assert next(gen_output2)[0, 0, 0, 0] == 15 * 5
# Tear down everything
enqueuer.stop()
enqueuer2.stop()
示例2: test_ordered_enqueuer_processes
# 需要导入模块: from keras.utils import OrderedEnqueuer [as 别名]
# 或者: from keras.utils.OrderedEnqueuer import get [as 别名]
def test_ordered_enqueuer_processes():
enqueuer = OrderedEnqueuer(TestSequence([3, 200, 200, 3]), use_multiprocessing=True)
enqueuer.start(3, 10)
gen_output = enqueuer.get()
acc = []
for i in range(100):
acc.append(next(gen_output)[0, 0, 0, 0])
assert acc == list(range(100)), "Order was not keep in GeneratorEnqueuer with processes"
enqueuer.stop()
示例3: test_on_epoch_end_processes
# 需要导入模块: from keras.utils import OrderedEnqueuer [as 别名]
# 或者: from keras.utils.OrderedEnqueuer import get [as 别名]
def test_on_epoch_end_processes():
enqueuer = OrderedEnqueuer(DummySequence([3, 200, 200, 3]), use_multiprocessing=True)
enqueuer.start(3, 10)
gen_output = enqueuer.get()
acc = []
for i in range(200):
acc.append(next(gen_output)[0, 0, 0, 0])
assert acc[100:] == list([k * 5 for k in range(100)]), "Order was not keep in GeneratorEnqueuer with processes"
enqueuer.stop()
示例4: test_ordered_enqueuer_threads_not_ordered
# 需要导入模块: from keras.utils import OrderedEnqueuer [as 别名]
# 或者: from keras.utils.OrderedEnqueuer import get [as 别名]
def test_ordered_enqueuer_threads_not_ordered():
enqueuer = OrderedEnqueuer(DummySequence([3, 200, 200, 3]),
use_multiprocessing=False,
shuffle=True)
enqueuer.start(3, 10)
gen_output = enqueuer.get()
acc = []
for i in range(100):
acc.append(next(gen_output)[0, 0, 0, 0])
assert acc != list(range(100)), "Order was not keep in GeneratorEnqueuer with threads"
enqueuer.stop()
示例5: test_ordered_enqueuer_fail_processes
# 需要导入模块: from keras.utils import OrderedEnqueuer [as 别名]
# 或者: from keras.utils.OrderedEnqueuer import get [as 别名]
def test_ordered_enqueuer_fail_processes():
enqueuer = OrderedEnqueuer(FaultSequence(), use_multiprocessing=True)
enqueuer.start(3, 10)
gen_output = enqueuer.get()
with pytest.raises(StopIteration):
next(gen_output)
示例6: test_ordered_enqueuer_fail_threads
# 需要导入模块: from keras.utils import OrderedEnqueuer [as 别名]
# 或者: from keras.utils.OrderedEnqueuer import get [as 别名]
def test_ordered_enqueuer_fail_threads():
enqueuer = OrderedEnqueuer(FaultSequence(), use_multiprocessing=False)
enqueuer.start(3, 10)
gen_output = enqueuer.get()
with pytest.raises(IndexError):
next(gen_output)