def ExampleGen(data_path, num_epochs=None):
 epoch = 0
 while True:
  if ((num_epochs is not None) and (epoch >= num_epochs)):
   break
  filelist = glob.glob(data_path)
  assert filelist, 'Empty filelist.'
  random.shuffle(filelist)
  for f in filelist:
   reader = open(f, 'rb')
   while True:
    len_bytes = reader.read(8)
    if (not len_bytes):
     break
    str_len = struct.unpack('q', len_bytes)[0]
    example_str = struct.unpack(('%ds' % str_len), reader.read(str_len))[0]
    (yield example_pb2.Example.FromString(example_str))
  epoch += 1

def ExampleGen ( data_path , num_epochs = None ) : epoch = 0 while True : if ( ( num_epochs is not None ) and ( epoch >= num_epochs ) ) : break filelist = glob . glob ( data_path ) assert filelist , 'Empty filelist.' random . shuffle ( filelist ) for f in filelist : reader = open ( f , 'rb' ) while True : len_bytes = reader . read ( 8 ) if ( not len_bytes ) : break str_len = struct . unpack ( 'q' , len_bytes ) [ 0 ] example_str = struct . unpack ( ( '%ds' % str_len ) , reader . read ( str_len ) ) [ 0 ] ( yield example_pb2 . Example . FromString ( example_str ) ) epoch += 1
generates tf .