Concept of trial and iteration

Hi,

I am absolutely new to Ray Tune and have a very simple question.
It’s about the distinction between the concepts of “trial” and “iteration”.
Let’s assume I have a basic neural network and simply want to use Ray tune to determine the optimal dropout rate, so that I only have the following in the config dictionary:

config = {"drop_out":tune.uniform(0.15, 0.7)}

If I now execute tune.run(…), the number of trials is determined by num_samples. At the moment I understand that in each trial a different dropout rate is tested, so it’s not quite clear to me what the “iter” parameter indicates in the results. Are different dropout rates also tested within each iteration?

I would be very grateful for an answer and apologise in advance for this very simple question.

Hey @hmars, thanks for the question!

Your understanding of what a “trial” here is correct - each trial will correspond to one hyperparameter configuration.

For the definition of an “iteration”, In the context of training a neural network you can most often think about it as an epoch. More specifically, each iteration corresponds to a call to tune.report(...) in your Trainable function. See the Function API snippet for a simple example.

Hey @matthewden , your answer is really helpful for me and thanks a lot for the link.

Just to be sure and look at the code from your example:

from ray import tune


def objective(x, a, b):  # Define an objective function.
    return a * (x ** 0.5) + b


def trainable(config):  # Pass a "config" dictionary into your trainable.

    for x in range(20):  # "Train" for 20 iterations and compute intermediate scores.
        score = objective(x, config["a"], config["b"])

        tune.report(score=score)  # Send the score to Tune.

So, if I only use the objective function from the example above, would each iteration of a trial always produce the same result, since unlike neural networks we have no change between the iterations respectively epochs?

Hey @hmars,

Try it out and see for yourself! :smiley: Since the objective function actually takes x as an input, you should expect score to change over each iteration.

Hey @matthewdeng ,

you are of course absolutely right, I overlooked the fact that it is iterated over x.

Thanks in any case for your help and have a nice week.