import tensorflow as tf

    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)
      encoded_image = tf.image.encode_png(image_placeholder)

      with tf.Session('') as sess:

        for j in range(num_images):
          sys.stdout.write('\r>> Reading file [%s] image %d' % (
              filename, offset + 1))
          sys.stdout.flush()

          if ('train' == name) and ( math.floor(offset / images_per_shard) > shard) :
            tfrecord_writer.close()
            shard = shard + 1
