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


Python utils.GeneratorEnqueuer方法代码示例

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

示例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() 
开发者ID:hello-sea,项目名称:DeepLearning_Wavelet-LSTM,代码行数:12,代码来源:data_utils_test.py

示例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) 
开发者ID:hello-sea,项目名称:DeepLearning_Wavelet-LSTM,代码行数:9,代码来源:data_utils_test.py

示例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) 
开发者ID:hello-sea,项目名称:DeepLearning_Wavelet-LSTM,代码行数:9,代码来源:data_utils_test.py

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

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

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

示例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() 
开发者ID:hello-sea,项目名称:DeepLearning_Wavelet-LSTM,代码行数:14,代码来源:data_utils_test.py

示例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() 
开发者ID:hello-sea,项目名称:DeepLearning_Wavelet-LSTM,代码行数:12,代码来源:data_utils_test.py

示例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() 
开发者ID:hello-sea,项目名称:DeepLearning_Wavelet-LSTM,代码行数:12,代码来源:data_utils_test.py

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


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