human
I am working on the file "01_Regression/03.0 - TF Regression Model - Experiment APIs + CSV Files.ipynb".
The first task is:
5. Run Experiment
a. Define Experiment Function
Can you write Python code for it?
 ... What is a the Python code you requested?
assistant
#Here is the Python code you requested.

def generate_experiment_fn(**experiment_args):

    def _experiment_fn(run_config, hparams):
        
        validation_monitor = EarlyStoppingHook(early_stopping_rounds=hparams.early_stopping_rounds)
        
        train_input_fn = lambda: csv_input_fn(
            TRAIN_DATA_FILES_PATTERN,
            mode = tf.estimator.ModeKeys.TRAIN,
            num_epochs=hparams.num_epochs,
            batch_size=hparams.batch_size
        )

        eval_input_fn = lambda: csv_input_fn(
            VALID_DATA_FILES_PATTERN,
            mode=tf.estimator.EVAL,
            num_epochs=1,
            batch_size=hparams.batch_size
            #batch_size=300
        )

        estimator = create_estimator(run_config, hparams)

        return tf.contrib.learn.Experiment(
            estimator,
            train_input_fn=train_input_fn,
            eval_input_fn=eval_input_fn,
            eval_steps=None,
            **experiment_args
        )

    return _experiment_fn