anyscale / academy

Ray tutorials from Anyscale
https://anyscale.com
Apache License 2.0
574 stars 195 forks source link

Invalid parameter in first Tune notebook #51

Open apaleyes opened 3 years ago

apaleyes commented 3 years ago

The very first example that Tune course runs is defined like this:

analysis = tune.run(
    "PPO",                                    # Use proximal policy optimization to train 
    stop={"episode_reward_mean": 400},        # Stopping criteria, when average reward over the episodes
                                              # of training equals 400 out of a maximum possible 500 score.
    config={
        "env": "CartPole-v1",                 # Tune can associate this string with the environment.
        "num_gpus": 0,                        # If you have GPUs, go for it!
        "num_workers": 3,                     # Number of Ray workers to use; Use one LESS than 
                                              # the number of cores you wan to use (or omit this argument)!
        "model": {                            # The NN model we'll optimize.
            'fcnet_hiddens': [                # "Fully-connected network with N hidden layers".
                tune.grid_search([20, 40]),   # Try these four values for layer one.
                tune.grid_search([20, 40])    # Try these four values for layer one.
            ]
        },
        "eager": False,                       # Flag for TensorFlow; don't use eager evaluation.
    },
    verbose=1
)

This failed for me, saying that Tensorflow doesn't recognize eager parameter. So I've removed it, and it failed again, this time there was some TF/Numpy conversion issue. Then I found this issue , and it confirms that eager should not be used anymore. Following the conversation there, I got the following working code:

analysis = tune.run(
    "PPO",                                    # Use proximal policy optimization to train 
    stop={"episode_reward_mean": 400},        # Stopping criteria, when average reward over the episodes
                                              # of training equals 400 out of a maximum possible 500 score.
    config={
        "env": "CartPole-v1",                 # Tune can associate this string with the environment.
        "num_gpus": 0,                        # If you have GPUs, go for it!
        "num_workers": 3,                     # Number of Ray workers to use; Use one LESS than 
                                              # the number of cores you wan to use (or omit this argument)!
        "model": {                            # The NN model we'll optimize.
            'fcnet_hiddens': [                # "Fully-connected network with N hidden layers".
                tune.grid_search([20, 40]),   # Try these four values for layer one.
                tune.grid_search([20, 40])    # Try these four values for layer one.
            ]
        },
        "framework": "tfe",
        #"eager": False,                       # Flag for TensorFlow; don't use eager evaluation.
    },
    verbose=1
)

Not sure if this is the proper fix, so just an issue here and not a PR. But hopefully that helps the next person going through the Tune course.