Tutorial 10: How to use FastEstimator Command Line Interface (CLI)¶
Overview¶
FastEstimator comes with a set of CLI commands that can help users train and test their models quickly. In this tutorial, we will go through the CLI usage and the arguments these CLI commands take. This tutorial is divided into the following sections:
How Does the CLI Work¶
fastestimator train
: the command will look for aget_estimator
function, invoke it, and then call thefit()
method on the returned estimator instance to start the training.fastestimator test
: the command will look for aget_estimator
function, invoke it, and then call thetest()
method on the returned estimator instance to run testing.fastestimator run
: the command will look for afastestimator_run
function and invoke it. Iffastestimator_run
is not available, it will instead look forget_estimator
, invoke it, and then callfit()
and/ ortest
depending on what data is available within the estimator's Pipeline.
¶
CLI Usage¶
In this section we will show the actual commands that we can use to train and test our models. We will use mnist_tf.py for illustration.
To call estimator.fit()
and start the training on terminal:
To call estimator.test()
and start testing on terminal:
To first call estimator.fit()
then estimator.test()
, you can use:
Sending Input Args to get_estimator
or fastestimator_run
¶
We can also pass arguments to the get_estimator
or fastestimator_run
functions from the CLI. The following code snippet shows the get_estimator
method for our MNIST example:
Next, we try to change these arguments in two ways:
Using --arg¶
To pass the arguments directly from the CLI we can use the --arg
format. The following shows an example of how we can set the number of epochs to 3 and batch_size to 64:
Using a JSON file¶
The other way we can send arguments is by using the --hyperparameters
argument and passing it a json file containing all the training hyperparameters like epochs, batch_size, optimizer, etc. This option is really useful when you want to repeat the training job more than once and/or the list of the hyperparameter is getting really long. The following shows an example JSON file and how it could be used for our MNIST example:
System argument¶
There are some default system arguments in the fastestimator train
and fastestimator test
commands. Here are a list of them:
* warmup
: Only available in fastestimator train
, it controls whether to perform warmup checking before the actual training starts. Default is True. Users can disable warmup before training by --warmup False
.
* summary
: Available in both fastestimator train
and fastestimator test
, this is the same argument used in estimator.fit()
or estimator.test()
. It allows users to specify experiment name when generating reports. For example, Users can set experiment name by --summary exp_name
.