Python keras.utils.GeneratorEnqueuer() Examples
The following are 30
code examples of keras.utils.GeneratorEnqueuer().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
keras.utils
, or try the search function
.
Example #1
Source File: data_utils_test.py From DeepLearning_Wavelet-LSTM with MIT License | 6 votes |
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)
Example #2
Source File: data_utils_test.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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()
Example #3
Source File: data_utils_test.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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)
Example #4
Source File: data_utils_test.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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)
Example #5
Source File: data_utils_test.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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)
Example #6
Source File: data_utils_test.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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()
Example #7
Source File: data_utils_test.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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()
Example #8
Source File: data_utils_test.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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()
Example #9
Source File: data_utils_test.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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()
Example #10
Source File: data_utils_test.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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()
Example #11
Source File: data_utils_test.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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()
Example #12
Source File: data_utils_test.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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()
Example #13
Source File: data_utils_test.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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()
Example #14
Source File: data_utils_test.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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()
Example #15
Source File: data_utils_test.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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()
Example #16
Source File: data_utils_test.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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()
Example #17
Source File: data_utils_test.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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()
Example #18
Source File: data_utils_test.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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()
Example #19
Source File: data_utils_test.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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)
Example #20
Source File: data_utils_test.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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)
Example #21
Source File: data_utils_test.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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()
Example #22
Source File: data_utils_test.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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()
Example #23
Source File: data_utils_test.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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()
Example #24
Source File: data_utils_test.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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()
Example #25
Source File: data_utils_test.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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()
Example #26
Source File: data_utils_test.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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()
Example #27
Source File: data_utils_test.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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()
Example #28
Source File: data_utils_test.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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()
Example #29
Source File: data_utils_test.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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)
Example #30
Source File: data_utils_test.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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()