def __init__(self, q, batch_iter): super(BatchProducer, self).__init__() threading.Thread.__init__(self) self.q = q self.batch_iter = batch_iter self.log = logger.get() self._stop = threading.Event() self.daemon = True
def __init__(self, batch_iter, max_queue_size=10, num_threads=5, log_queue=20, name=None): """ Data provider wrapper that supports concurrent data fetching. """ super(ConcurrentBatchIterator, self).__init__() self.max_queue_size = max_queue_size self.num_threads = num_threads self.q = queue.Queue(maxsize=max_queue_size) self.log = logger.get() self.batch_iter = batch_iter self.fetchers = [] self.init_fetchers() self.counter = 0 self.relaunch = True self._stopped = False self.log_queue = log_queue self.name = name pass
"""Unit tests for multi-pass model.""" from __future__ import (absolute_import, division, print_function, unicode_literals) import os import numpy as np import tensorflow as tf from resnet.configs import get_config from resnet.configs import test_configs from resnet.models.model_factory import get_model, get_multi_gpu_model from resnet.models.multi_pass_model import MultiPassModel from resnet.models.resnet_model import ResNetModel from resnet.utils import logger log = logger.get() FOLDER = "tmp" CKPT_FNAME = os.path.join(FOLDER, "test_multi_pass.ckpt") class MultiPassModelTests(tf.test.TestCase): def _test_single_pass(self, method): config = get_config("resnet-test") config.momentum = 0.0 config.base_learn_rate = 1e-1 np.random.seed(0) BSIZE = config.batch_size xval = np.random.uniform( -1.0, 1.0, [BSIZE, config.height, config.width, config.num_channel]).astype(np.float32) yval = np.floor(np.random.uniform(0, 9.9, [BSIZE])).astype(np.int32)