Access to Hyperparameters artifacts inside tuner_fn TFX

Hi all,

I want to have access to a Hyperparameters artifact containing hyper-parameters values computed from a previous run. I could then perform a hyper-parameters search with some hyper-parameters values fixed (e.g., the number of layers to be able to load a previously trained model) and to fine-tune the others (e.g., the learning rate).

I tried to use a Resolver component with a LatestArtifactStrategy and two inputs channels, one for the Model artifact and one for the Hyperparameters artifact. I then pass the outputs of this Resolver component to the Tuner component in the following way:

resolver = Resolver(

tuner = Tuner(

Unfortunately, the resolver component only succeeded to load the Model artifact but not the Hyperparameters one.

One trick that I did is to write a custom Trainer executor that loads the Hyperparameters artifact and copies the ‘best_hyperparameters.txt’ file to the model directory. I could then access this file inside the tuner_fn thanks to the fn_args.base_model attribute but it doesn’t appear to be a valid option.

What is the recommended way to pass previous run artifacts to downstream components ?
In this case how to access hyper-parameters used to train a model, without having to hand save the parameters inside the model directory ? Or how to pass it to the tuner_fn beside the custom_config ?

Thanks :slight_smile:

For Trainer component, it can take a hparam channel.

For Tuner component to take a hparam channel, you need to customize the component and its spec.