我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用reader.ptb_producer()。
def testPtbProducer(self): raw_data = [4, 3, 2, 1, 0, 5, 6, 1, 1, 1, 1, 0, 3, 4, 1] batch_size = 3 num_steps = 2 x, y = reader.ptb_producer(raw_data, batch_size, num_steps) with self.test_session() as session: coord = tf.train.Coordinator() tf.train.start_queue_runners(session, coord=coord) try: xval, yval = session.run([x, y]) self.assertAllEqual(xval, [[4, 3], [5, 6], [1, 0]]) self.assertAllEqual(yval, [[3, 2], [6, 1], [0, 3]]) xval, yval = session.run([x, y]) self.assertAllEqual(xval, [[2, 1], [1, 1], [3, 4]]) self.assertAllEqual(yval, [[1, 0], [1, 1], [4, 1]]) finally: coord.request_stop() coord.join()
def __init__(self, config, data, name=None): self.batch_size = batch_size = config.batch_size self.num_steps = num_steps = config.num_steps self.epoch_size = ((len(data) // batch_size) - 1) // num_steps self.input_data, self.targets = reader.ptb_producer( data, batch_size, num_steps, name=name)
def __init__(self, config, data, name=None): self.batch_size = batch_size = config.batch_size self.time_steps = time_steps = config.time_steps self.epoch_size = ((len(data) // batch_size) - 1) // time_steps self.input_data, self.targets = reader.ptb_producer( data, batch_size, time_steps, name=name)
def __init__(self, data, name=None): self.batch_size = batch_size = FLAGS.batch_size self.num_steps = num_steps = FLAGS.num_steps self.epoch_size = ((len(data) // batch_size) - 1) // num_steps self.input_data, self.targets = reader.ptb_producer( data, batch_size, num_steps, name=name)
def __init__(self, config, data, name=None): ''' num_steps: the number of timesteps (or unrolled steps) ''' self.batch_size = batch_size = config.batch_size self.num_steps = num_steps = config.num_steps self.epoch_size = ((len(data) // batch_size) - 1) // num_steps self.input_data, self.targets = reader.ptb_producer( data, batch_size, num_steps, name=name)