C4W3 - TFX on Google Cloud Vertex Pipelines Graded Lab Help Required

Ok. So I have a doubt about the way arguments are passed in the Module file by the TFX Trainer component.

Image 1 - Module File Snippet

Image 2 - Instantiating Trainer Component
image

What I am confused about is, when calling the tfx.components.Trainer(), we are passing only the following :
1. module_file=module_file,
2. examples=example_gen.outputs[‘examples’],
3. train_args=tfx.proto.TrainArgs(num_steps=100),
4. eval_args=tfx.proto.EvalArgs(num_steps=5))

So when in the actual Module file, how does the run function resolve the following:
fn_args.train_files,
fn_args.eval_files,
fn_args.data_accessor,
fn_args.serving_model_dir

Additionally, for fn_args.train_steps and fn_args.eval_steps, are these params auto-resolved from train and eval args?

Thanks in Advance

Please read this comment:
# TFX Trainer will call this function
So, look at tfx code if curious about how the parameters are populated during invocation.

@Bhavin_Rathava
When you pass the module_file argument to the tfx.components.Trainer() function, you are specifying the path to the Python file that contains the TensorFlow model. The file define the run() function, which takes an argument tfx.components.FnArgs. This argument contains information about the training and evaluation data, such as the file paths and data accessors.

The fn_args.train_files and fn_args.eval_files fields specify the file paths for the training and evaluation data, respectively. These paths are determined by the example_gen output that you passed as the examples argument to the tfx.components.Trainer() function.

The fn_args.data_accessor field specifies the data accessor object that provides access to the training and evaluation data. This is also determined by the example_gen output that you passed as the examples argument.

The fn_args.serving_model_dir field specifies the directory where the trained model will be saved in a format that can be served by TensorFlow Serving. This is specified in the trainer_fn function in the module file.

Regarding fn_args.train_steps and fn_args.eval_steps, these fields are not auto-resolved from train_args and eval_args. Instead, you should define them explicitly in your trainer_fn function, based on the values passed in train_args and eval_args. For example, you might set fn_args.train_steps to train_args.num_steps and fn_args.eval_steps to eval_args.num_steps.

@Isaak_Kamau Thanks for the reply! That clears it up! Hope you have a great day!

1 Like