(is_training = True)
return batch, size // Params.batch_size
Loads training data and put them in queues
Loads training data and put them in queues
Loads training data and put them in queues
def get_batch(is_training = True):
    """Loads training data and put them in queues"""
    with tf.device('/cpu:0'):
        # Load dataset
        input_list, shapes = load_data(Params.train_dir if is_training else Params.dev_dir)
        indices = input_list[-1]

        train_ind = np.arange(indices.shape[0],dtype = np.int32)
        np.random.shuffle(train_ind)

        size = Params.data_size
        if Params.data_size > indices.shape[0] or Params.data_size == -1:
            size = indices.shape[0]
        ind_list = tf.convert_to_tensor(train_ind[:size])

        # Create Queues
        ind_list = tf.train.slice_input_producer([ind_list], shuffle=True)

        @producer_func
        def get_data(ind):
            '''From `_inputs`, which has been fetched from slice queues,
               then enqueue them again.
            '''
            return [np.reshape(input_[ind], shapes[i]) for i,input_ in enumerate(input_list)]

        data = get_data(inputs=ind_list,
                        dtypes=[np.int32]*9,
                        capacity=Params.batch_size*32,
                        num_threads=6)

        # create batch queues
        batch = tf.train.batch(data,
                                shapes=shapes,
                                num_threads=2,
                                batch_size=Params.batch_size,
                                capacity=Params.batch_size*32,
                                dynamic_pad=True)

    return batch, size // Params.batch_size
def get_batch ( is_training = True ) : with tf . device ( '/cpu:0' ) : # Load dataset input_list , shapes = load_data ( Params . train_dir if is_training else Params . dev_dir ) indices = input_list [ - 1 ] train_ind = np . arange ( indices . shape [ 0 ] , dtype = np . int32 ) np . random . shuffle ( train_ind ) size = Params . data_size if Params . data_size > indices . shape [ 0 ] or Params . data_size == - 1 : size = indices . shape [ 0 ] ind_list = tf . convert_to_tensor ( train_ind [ : size ] ) # Create Queues ind_list = tf . train . slice_input_producer ( [ ind_list ] , shuffle = True ) @ producer_func def get_data ( ind ) : '''From `_inputs`, which has been fetched from slice queues,
               then enqueue them again.
            ''' return [ np . reshape ( input_ [ ind ] , shapes [ i ] ) for i , input_ in enumerate ( input_list ) ] data = get_data ( inputs = ind_list , dtypes = [ np . int32 ] * 9 , capacity = Params . batch_size * 32 , num_threads = 6 ) # create batch queues batch = tf . train . batch ( data , shapes = shapes , num_threads = 2 , batch_size = Params . batch_size , capacity = Params . batch_size * 32 , dynamic_pad = True ) return batch , size // Params . batch_size