bert icon indicating copy to clipboard operation
bert copied to clipboard

train_batch_size in run_classifier.py

Open awasthiabhijeet opened this issue 8 years ago • 3 comments

Below is input_fn in run_classifier.py. Is batch_size same as train_batch_size ? I guess no, because params are not passed to None to the estimator. Should batch_size be same as train_batch_size?

def input_fn(params):
    """The actual input function."""
    batch_size = params["batch_size"]

    # For training, we want a lot of parallel reading and shuffling.
    # For eval, we want no shuffling and parallel reading doesn't matter.
    d = tf.data.TFRecordDataset(input_file)
    if is_training:
      d = d.repeat()
      d = d.shuffle(buffer_size=100)

    d = d.apply(
        tf.contrib.data.map_and_batch(
            lambda record: _decode_record(record, name_to_features),
            batch_size=batch_size,
            drop_remainder=drop_remainder))

    return d

awasthiabhijeet avatar Dec 02 '18 15:12 awasthiabhijeet

I think not.

HaodaY avatar Dec 05 '18 01:12 HaodaY

Not. "batch_size" is not sames as "train_batch_size". For training, we make a parallel reading and shuffling. For eval, we don't. For both, apply map_and_batch func. I think it's the logic

monanahe avatar Dec 05 '18 06:12 monanahe

"input_fn and model_fn will receive train_batch_size or eval_batch_size unmodified as params['batch_size']." Details in https://www.tensorflow.org/api_docs/python/tf/contrib/tpu/TPUEstimator.

shuaihhx avatar Dec 05 '18 07:12 shuaihhx