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


Python OrderedEnqueuer.get方法代码示例

本文整理汇总了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()
开发者ID:Bjoux2,项目名称:keras,代码行数:30,代码来源:data_utils_test.py

示例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()
开发者ID:rilut,项目名称:keras,代码行数:11,代码来源:data_utils_test.py

示例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()
开发者ID:Bjoux2,项目名称:keras,代码行数:11,代码来源:data_utils_test.py

示例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()
开发者ID:Bjoux2,项目名称:keras,代码行数:13,代码来源:data_utils_test.py

示例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)
开发者ID:rilut,项目名称:keras,代码行数:8,代码来源:data_utils_test.py

示例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)
开发者ID:poolio,项目名称:keras,代码行数:8,代码来源:data_utils_test.py


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