Python keras.utils.OrderedEnqueuer() Examples
The following are 30
code examples of keras.utils.OrderedEnqueuer().
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 | 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 #2
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 #3
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 #4
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 #5
Source File: data_utils_test.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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()
Example #6
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 #7
Source File: data_utils_test.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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)
Example #8
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 #9
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 #10
Source File: data_utils_test.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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)
Example #11
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 #12
Source File: data_utils_test.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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()
Example #13
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 #14
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 #15
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 #16
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 #17
Source File: data_utils_test.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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)
Example #18
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 #19
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 #20
Source File: data_utils_test.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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)
Example #21
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 #22
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 #23
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 #24
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 #25
Source File: data_utils_test.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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()
Example #26
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 #27
Source File: data_utils_test.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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)
Example #28
Source File: trainer.py From deephar with MIT License | 5 votes |
def __init__(self, models, generators, workers=1, shuffle=True, max_queue_size=10, print_full_losses=False): assert len(models) == len(generators), \ 'ValueError: models and generators should be lists of same size' if type(workers) is not list: workers = len(models)*[workers] self.models = models self.output_generators = [] self.batch_logs = {} self.print_full_losses = print_full_losses metric_names = [] batch_size = 0 for i in range(len(models)): assert isinstance(generators[i], BatchLoader), \ 'Only BatchLoader class is supported' batch_size += generators[i].get_batch_size() enqueuer = OrderedEnqueuer(generators[i], shuffle=shuffle) enqueuer.start(workers=workers[i], max_queue_size=max_queue_size) self.output_generators.append(enqueuer.get()) metric_names.append('loss%d' % i) if self.print_full_losses: for out in models[i].outputs: metric_names.append(out.name.split('/')[0]) self.batch_logs['size'] = batch_size self.metric_names = metric_names
Example #29
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 #30
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()