import tensorflow as tf


  if 'train' == name:
    record_filename = _get_output_filename(dataset_dir, name, shard, FLAGS.train_shards)
  elif 'test' == name:
    record_filename = _get_output_filename(dataset_dir, name)
  else:
    raise ValueError('Illegal dataset name')

  tfrecord_writer = tf.python_io.TFRecordWriter(record_filename)

  for filename in filenames:
    with tf.gfile.Open(filename, 'r') as f:
      data = cPickle.load(f)

    images = data['data']
    num_images = images.shape[0]

    images = images.reshape((num_images, 3, 32, 32))
    labels = data['labels']

    with tf.Graph().as_default():
      image_placeholder = tf.placeholder(dtype=tf.uint8)
