yangkevin2 / neurips2021-lap3

17 stars 0 forks source link

AttributeError: 'SwimmerEnv' object has no attribute 'max_episode_steps' #1

Open xinhongri opened 3 years ago

xinhongri commented 3 years ago

How to solve the problem?

parser.add_argument('--num_trials', type=int, default=32, help='evaluate average reward over X trials')    
parser.add_argument('--num_threads', type=int, default=1, help='number of envs to run in parallel')
parser.add_argument('--seed', type=int, default=123, help='seed for eval')
parser.add_argument('--device', type=str, default='cpu', choices=['cpu', 'cuda'])

# printing/logging
parser.add_argument('--render', action='store_true', default=False, help='render environments for visualization')
parser.add_argument('--visualize_samples', action='store_true', default=False, help='TSNE to visualize samples in a given planning iteration')
parser.add_argument('--verbose', action='store_true', default=False, help='more logging')
parser.add_argument('--quiet', action='store_true', default=False, help='minimal logging')
parser.add_argument('--logdir', type=str, default=None, help='directory to log trajectories to')

# env args
parser.add_argument('--env', type=str, default='Swimmer-v2', choices=list(ENV_INFO.keys()), help='env to run trials on')
parser.add_argument('--max_env_steps', type=int, default=None, help='limit max num steps in env for faster evaluation')

# general method args
parser.add_argument('--method', type=str, default='lamcts-planning', choices=list(PLANNING_METHODS.keys()), help='planning method')
parser.add_argument('--horizon', type=int, default=1000, help='evaluate discounted reward over next T timesteps when planning for lamcts')
parser.add_argument('--replan_freq', type=int, default=1000, help='how often to replan')
parser.add_argument('--iterations', type=int, default=1000, help='num iterations for lamcts or random shooting')
parser.add_argument('--cem_iters', type=int, default=10, help='maxits for CEM')

# lamcts-specific args
parser.add_argument('--solver', type=str, default='cmaes', choices=['cmaes'], help='leaf solver')
parser.add_argument('--init_within_leaf', type=str, default='mean', choices=['mean', 'random', 'max'], help='how to choose initial value within leaf for cmaes and gradient')
parser.add_argument('--gamma', type=float, default=1, help='discount for reward')
parser.add_argument('--Cp', type=float, default=1, help='Cp for MCTS')
parser.add_argument('--cmaes_sigma_mult', type=float, default=1, help='multiplier for cmaes sigma in solver')
parser.add_argument('--init_sigma_mult', type=float, default=1, help='std when sampling initial points')
parser.add_argument('--gradient_step', type=float, default=1, help='multiplier for gradient step in solver if using gradient solver')
parser.add_argument('--treeify_freq', type=int, default=50, help='redo the dynamic treeify every so many steps')
parser.add_argument('--ninits', type=int, default=50, help='ninits for lamcts')
parser.add_argument('--init_file', type=str, default=None, help='file with inits, or generate randomly if not provided')
parser.add_argument('--leaf_size', type=int, default=20, help='min leaf size before splitting')
parser.add_argument('--samples_per_iteration', type=int, default=1, 
                    help='enable sampling more nodes/fn evals at a time for efficiency (only remake the tree periodically); \
                          also controls the number of cmaes evals at a leaf if cmaes is the leaf solver')
parser.add_argument('--splitter_type', type=str, default='kmeans', choices=['kmeans', 'linreg', 'value'], help='how to split nodes for LaMCTS. value = just split in half based on value')
parser.add_argument('--split_metric', type=str, default='max', choices=['mean', 'max'], help='how to evaluate which child is best. applies to kmeans and value split types')
parser.add_argument('--no_gpr', action='store_true', default=False, help='if set, no gaussian process reranking for samples at leaves')
parser.add_argument('--latent', action='store_true', default=False, help='if set, use latent space for LaMCTS')
parser.add_argument('--latent_samples', action='store_true', default=False, help='if set, use latent space for LaMCTS sampling at leaves as well')
parser.add_argument('--latent_ckpt', type=str, default=None, help='load latent space ckpt from file if given')
parser.add_argument('--latent_model', type=str, default=None, choices=['pca', 'cnn', 'vae', 'realnvp', 'identity'], help='whether to use vae or normalizing flow')
parser.add_argument('--sample_latent_model', type=str, default=None, choices=['pca', 'cnn', 'vae', 'realnvp', 'identity'], help='whether to use vae or normalizing flow for samples')
parser.add_argument('--pca_latent_dim', type=int, default=32, help='latent dim if learning pca on the fly')
parser.add_argument('--final_obs_split', action='store_true', default=False, help='split using final states')
parser.add_argument('--action_seq_split', action='store_true', default=False, help='minimal logging')
yangkevin2 commented 3 years ago

Hey, sorry I missed the issues and thanks for the email. We hadn't fully tested all the setup from scratch previously; I updated the README instructions accordingly.

The Mujoco envs are not actually properly supported at the moment; they were just some preliminary things we tried previously and they're not in the paper. If you need them, you can probably modify the corresponding attributes in lamcts_planning/envs/env_info.py, and run similarly to the miniworld environments, maybe needing some other code changes and/or tuning some other parameters as well.