當前位置: 首頁>>代碼示例>>Python>>正文


Python utils.OrderedEnqueuer方法代碼示例

本文整理匯總了Python中keras.utils.OrderedEnqueuer方法的典型用法代碼示例。如果您正苦於以下問題:Python utils.OrderedEnqueuer方法的具體用法?Python utils.OrderedEnqueuer怎麽用?Python utils.OrderedEnqueuer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在keras.utils的用法示例。


在下文中一共展示了utils.OrderedEnqueuer方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_ordered_enqueuer_threads

# 需要導入模塊: from keras import utils [as 別名]
# 或者: from keras.utils import OrderedEnqueuer [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

示例2: test_ordered_enqueuer_threads_not_ordered

# 需要導入模塊: from keras import utils [as 別名]
# 或者: from keras.utils import OrderedEnqueuer [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

示例3: test_ordered_enqueuer_processes

# 需要導入模塊: from keras import utils [as 別名]
# 或者: from keras.utils import OrderedEnqueuer [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

示例4: test_ordered_enqueuer_fail_threads

# 需要導入模塊: from keras import utils [as 別名]
# 或者: from keras.utils import OrderedEnqueuer [as 別名]
def test_ordered_enqueuer_fail_threads():
    enqueuer = OrderedEnqueuer(FaultSequence(), use_multiprocessing=False)
    enqueuer.start(3, 10)
    gen_output = enqueuer.get()
    with pytest.raises(StopIteration):
        next(gen_output) 
開發者ID:hello-sea,項目名稱:DeepLearning_Wavelet-LSTM,代碼行數:8,代碼來源:data_utils_test.py

示例5: test_on_epoch_end_processes

# 需要導入模塊: from keras import utils [as 別名]
# 或者: from keras.utils import OrderedEnqueuer [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

示例6: test_on_epoch_end_threads

# 需要導入模塊: from keras import utils [as 別名]
# 或者: from keras.utils import OrderedEnqueuer [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

示例7: test_ordered_enqueuer_fail_processes

# 需要導入模塊: from keras import utils [as 別名]
# 或者: from keras.utils import OrderedEnqueuer [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:hello-sea,項目名稱:DeepLearning_Wavelet-LSTM,代碼行數:8,代碼來源:data_utils_test.py

示例8: test_context_switch

# 需要導入模塊: from keras import utils [as 別名]
# 或者: from keras.utils import OrderedEnqueuer [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:hello-sea,項目名稱:DeepLearning_Wavelet-LSTM,代碼行數:30,代碼來源:data_utils_test.py


注:本文中的keras.utils.OrderedEnqueuer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。