本文整理汇总了Python中keras.utils.GeneratorEnqueuer方法的典型用法代码示例。如果您正苦于以下问题:Python utils.GeneratorEnqueuer方法的具体用法?Python utils.GeneratorEnqueuer怎么用?Python utils.GeneratorEnqueuer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类keras.utils
的用法示例。
在下文中一共展示了utils.GeneratorEnqueuer方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_generator_enqueuer_threads
# 需要导入模块: from keras import utils [as 别名]
# 或者: from keras.utils import GeneratorEnqueuer [as 别名]
def test_generator_enqueuer_threads():
enqueuer = GeneratorEnqueuer(create_generator_from_sequence_threads(
DummySequence([3, 200, 200, 3])), use_multiprocessing=False)
enqueuer.start(3, 10)
gen_output = enqueuer.get()
acc = []
for i in range(100):
acc.append(int(next(gen_output)[0, 0, 0, 0]))
"""
Not comparing the order since it is not guaranteed.
It may get ordered, but not a lot, one thread can take the GIL before he was supposed to.
"""
assert len(set(acc) - set(range(100))) == 0, "Output is not the same"
enqueuer.stop()
示例2: test_generator_enqueuer_processes
# 需要导入模块: from keras import utils [as 别名]
# 或者: from keras.utils import GeneratorEnqueuer [as 别名]
def test_generator_enqueuer_processes():
enqueuer = GeneratorEnqueuer(create_generator_from_sequence_pcs(
DummySequence([3, 200, 200, 3])), use_multiprocessing=True)
enqueuer.start(3, 10)
gen_output = enqueuer.get()
acc = []
for i in range(100):
acc.append(int(next(gen_output)[0, 0, 0, 0]))
assert acc != list(range(100)), "Order was keep in GeneratorEnqueuer with processes"
enqueuer.stop()
示例3: test_generator_enqueuer_fail_threads
# 需要导入模块: from keras import utils [as 别名]
# 或者: from keras.utils import GeneratorEnqueuer [as 别名]
def test_generator_enqueuer_fail_threads():
enqueuer = GeneratorEnqueuer(create_generator_from_sequence_threads(
FaultSequence()), use_multiprocessing=False)
enqueuer.start(3, 10)
gen_output = enqueuer.get()
with pytest.raises(IndexError):
next(gen_output)
示例4: test_generator_enqueuer_fail_processes
# 需要导入模块: from keras import utils [as 别名]
# 或者: from keras.utils import GeneratorEnqueuer [as 别名]
def test_generator_enqueuer_fail_processes():
enqueuer = GeneratorEnqueuer(create_generator_from_sequence_pcs(
FaultSequence()), use_multiprocessing=True)
enqueuer.start(3, 10)
gen_output = enqueuer.get()
with pytest.raises(IndexError):
next(gen_output)
示例5: test_ordered_enqueuer_threads
# 需要导入模块: from keras import utils [as 别名]
# 或者: from keras.utils import GeneratorEnqueuer [as 别名]
def test_ordered_enqueuer_threads():
enqueuer = OrderedEnqueuer(DummySequence([3, 200, 200, 3]), use_multiprocessing=False)
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()
示例6: test_ordered_enqueuer_processes
# 需要导入模块: from keras import utils [as 别名]
# 或者: from keras.utils import GeneratorEnqueuer [as 别名]
def test_ordered_enqueuer_processes():
enqueuer = OrderedEnqueuer(DummySequence([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()
示例7: test_on_epoch_end_processes
# 需要导入模块: from keras import utils [as 别名]
# 或者: from keras.utils import GeneratorEnqueuer [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()
示例8: test_on_epoch_end_threads
# 需要导入模块: from keras import utils [as 别名]
# 或者: from keras.utils import GeneratorEnqueuer [as 别名]
def test_on_epoch_end_threads():
enqueuer = OrderedEnqueuer(DummySequence([3, 200, 200, 3]), use_multiprocessing=False)
enqueuer.start(3, 10)
gen_output = enqueuer.get()
acc = []
for i in range(100):
acc.append(next(gen_output)[0, 0, 0, 0])
acc = []
for i in range(100):
acc.append(next(gen_output)[0, 0, 0, 0])
assert acc == list([k * 5 for k in range(100)]), "Order was not keep in GeneratorEnqueuer with processes"
enqueuer.stop()
示例9: test_finite_generator_enqueuer_threads
# 需要导入模块: from keras import utils [as 别名]
# 或者: from keras.utils import GeneratorEnqueuer [as 别名]
def test_finite_generator_enqueuer_threads():
enqueuer = GeneratorEnqueuer(create_finite_generator_from_sequence_threads(
DummySequence([3, 200, 200, 3])), use_multiprocessing=False)
enqueuer.start(3, 10)
gen_output = enqueuer.get()
acc = []
for output in gen_output:
acc.append(int(output[0, 0, 0, 0]))
assert set(acc) == set(range(100)), "Output is not the same"
enqueuer.stop()
示例10: test_finite_generator_enqueuer_processes
# 需要导入模块: from keras import utils [as 别名]
# 或者: from keras.utils import GeneratorEnqueuer [as 别名]
def test_finite_generator_enqueuer_processes():
enqueuer = GeneratorEnqueuer(create_finite_generator_from_sequence_pcs(
DummySequence([3, 200, 200, 3])), use_multiprocessing=True)
enqueuer.start(3, 10)
gen_output = enqueuer.get()
acc = []
for output in gen_output:
acc.append(int(output[0, 0, 0, 0]))
assert acc != list(range(100)), "Order was keep in GeneratorEnqueuer with processes"
enqueuer.stop()
示例11: test_ordered_enqueuer_threads_not_ordered
# 需要导入模块: from keras import utils [as 别名]
# 或者: from keras.utils import GeneratorEnqueuer [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()