Best Python code snippet using avocado_python
image_param_list.py
Source:image_param_list.py
1import argparse2import random3import torch4epochs=605def params_np():6 7 parser_np = argparse.ArgumentParser(description='np')8 parser_np.add_argument('--no-cuda', action='store_true', default=False,9 help='disables CUDA training')10 parser_np.add_argument('--seed', type=int, default=1, metavar='S',11 help='random seed (default: 1)')12 parser_np.add_argument('--log-interval', type=int, default=1, metavar='N',13 help='how many batches to wait before logging training status')14 parser_np.add_argument('--batch_size', type=int, default=8, metavar='N',15 help='input batch size for training')16 parser_np.add_argument('--epochs', type=int, default=epochs, metavar='N',17 help='number of epochs to train')18 19 parser_np.add_argument('--dim_x', type=int, default=2, metavar='N',20 help='dimension of input')21 parser_np.add_argument('--dim_y', type=int, default=3, metavar='N',22 help='dimension of output')23 24 parser_np.add_argument('--dim_h_lat', type=int, default=128, metavar='N',25 help='dim of hidden units for encoders')26 parser_np.add_argument('--num_h_lat', type=int, default=3, metavar='N',27 help='num of layers for encoders')28 parser_np.add_argument('--dim_lat', type=int, default=128, metavar='N',29 help='dimension of z, the global latent variable') 30 31 parser_np.add_argument('--dim_h', type=int, default=128, metavar='N',32 help='dim of hidden units for decoders') 33 parser_np.add_argument('--num_h', type=int, default=5, metavar='N') 34 parser_np.add_argument('--act_type', type=str, default='ReLU', metavar='N') 35 parser_np.add_argument('--amort_y', type=bool, default=False, metavar='N')36 37 args = parser_np.parse_args()38 args.cuda = not args.no_cuda and torch.cuda.is_available()39 torch.manual_seed(args.seed)40 random.seed(args.seed)41 device = torch.device("cuda" if args.cuda else "cpu")42 return args,random,device43def params_attn_np():44 45 parser_attn_np = argparse.ArgumentParser(description='attn_np')46 parser_attn_np.add_argument('--no-cuda', action='store_true', default=False,47 help='disables CUDA training')48 parser_attn_np.add_argument('--seed', type=int, default=1, metavar='S',49 help='random seed (default: 1)')50 parser_attn_np.add_argument('--log-interval', type=int, default=1, metavar='N',51 help='how many batches to wait before logging training status')52 parser_attn_np.add_argument('--batch_size', type=int, default=8, metavar='N',53 help='input batch size for training')54 parser_attn_np.add_argument('--epochs', type=int, default=epochs, metavar='N',55 help='number of epochs to train')56 57 parser_attn_np.add_argument('--dim_x', type=int, default=2, metavar='N',58 help='dimension of input')59 parser_attn_np.add_argument('--dim_y', type=int, default=3, metavar='N',60 help='dimension of output')61 62 parser_attn_np.add_argument('--dim_h_lat', type=int, default=32, metavar='N',63 help='dim of hidden units for encoders')64 parser_attn_np.add_argument('--num_h_lat', type=int, default=2, metavar='N',65 help='num of layers for encoders')66 parser_attn_np.add_argument('--dim_lat', type=int, default=32, metavar='N',67 help='dimension of z, the global latent variable')68 parser_attn_np.add_argument('--num_head', type=int, default=2, metavar='N',69 help='num of heads for attention networks') 70 parser_attn_np.add_argument('--dim_emb_x', type=int, default=32, metavar='N',71 help='num of heads for attention networks') 72 73 parser_attn_np.add_argument('--dim_h', type=int, default=128, metavar='N') 74 parser_attn_np.add_argument('--num_h', type=int, default=5, metavar='N') 75 parser_attn_np.add_argument('--act_type', type=str, default='ReLU', metavar='N') 76 parser_attn_np.add_argument('--amort_y', type=bool, default=False, metavar='N')77 78 args = parser_attn_np.parse_args()79 args.cuda = not args.no_cuda and torch.cuda.is_available()80 torch.manual_seed(args.seed)81 device = torch.device("cuda" if args.cuda else "cpu")82 return args,random,device83def params_moe_np():84 85 parser_moe_np = argparse.ArgumentParser(description='moe_nps')86 parser_moe_np.add_argument('--no-cuda', action='store_true', default=False,87 help='disables CUDA training')88 parser_moe_np.add_argument('--seed', type=int, default=1, metavar='S',89 help='random seed (default: 1)')90 parser_moe_np.add_argument('--log-interval', type=int, default=1, metavar='N',91 help='how many batches to wait before logging training status')92 parser_moe_np.add_argument('--batch_size', type=int, default=32, metavar='N',93 help='input batch size for training')94 parser_moe_np.add_argument('--epochs', type=int, default=epochs, metavar='N',95 help='number of epochs to train') 96 parser_moe_np.add_argument('--dim_x', type=int, default=2, metavar='N',97 help='dimension of input')98 parser_moe_np.add_argument('--dim_y', type=int, default=3, metavar='N',99 help='dimension of output')100 101 parser_moe_np.add_argument('--dim_h_lat', type=int, default=128, metavar='N',102 help='dim of hidden units for encoders')103 parser_moe_np.add_argument('--num_h_lat', type=int, default=3, metavar='N',104 help='num of layers for encoders')105 parser_moe_np.add_argument('--dim_lat', type=int, default=128, metavar='N',106 help='dimension of z, the global latent variable')107 108 parser_moe_np.add_argument('--num_lat', type=int, default=2, metavar='N',109 help='num of latent variables')110 parser_moe_np.add_argument('--experts_in_gates', type=bool, default=False, metavar='N',111 help='whether experts as input for encoders')112 parser_moe_np.add_argument('--dim_logit_h', type=int, default=32, metavar='N',113 help='dim of hidden units for encoders') 114 parser_moe_np.add_argument('--num_logit_layers', type=int, default=2, metavar='N',115 help='dim of hidden units for encoders') 116 parser_moe_np.add_argument('--temperature', type=int, default=0.1, metavar='N') 117 parser_moe_np.add_argument('--hard', type=bool, default=False, metavar='N')118 parser_moe_np.add_argument('--gumbel_max', type=bool, default=True, metavar='N')119 parser_moe_np.add_argument('--info_bottleneck', type=bool, default=False, metavar='N') 120 121 parser_moe_np.add_argument('--dim_h', type=int, default=128, metavar='N',122 help='dim of hidden units for decoders') 123 parser_moe_np.add_argument('--num_h', type=int, default=5, metavar='N',124 help='num of layers for decoders') 125 parser_moe_np.add_argument('--act_type', type=str, default='LeakyReLU', metavar='N',126 help='type of activation units') 127 parser_moe_np.add_argument('--amort_y', type=bool, default=False, metavar='N')128 129 args = parser_moe_np.parse_args()130 args.cuda = not args.no_cuda and torch.cuda.is_available()131 torch.manual_seed(args.seed)132 random.seed(args.seed)133 device = torch.device("cuda" if args.cuda else "cpu")134 return args,random,device135def params_moe_condnp():136 137 parser_moe_condnp = argparse.ArgumentParser(description='moe_condnps')138 parser_moe_condnp.add_argument('--no-cuda', action='store_true', default=False,139 help='disables CUDA training')140 parser_moe_condnp.add_argument('--seed', type=int, default=1, metavar='S',141 help='random seed (default: 1)')142 parser_moe_condnp.add_argument('--log-interval', type=int, default=1, metavar='N',143 help='how many batches to wait before logging training status')144 parser_moe_condnp.add_argument('--batch_size', type=int, default=8, metavar='N',145 help='input batch size for training')146 parser_moe_condnp.add_argument('--epochs', type=int, default=epochs, metavar='N',147 help='number of epochs to train')148 parser_moe_condnp.add_argument('--dim_x', type=int, default=2, metavar='N',149 help='dimension of input')150 parser_moe_condnp.add_argument('--dim_y', type=int, default=3, metavar='N',151 help='dimension of output')152 153 parser_moe_condnp.add_argument('--dim_h_lat', type=int, default=128, metavar='N',154 help='dim of hidden units for encoders')155 parser_moe_condnp.add_argument('--num_h_lat', type=int, default=3, metavar='N',156 help='num of layers for encoders')157 parser_moe_condnp.add_argument('--dim_lat', type=int, default=128, metavar='N',158 help='dimension of z, the global latent variable')159 160 parser_moe_condnp.add_argument('--num_lat', type=int, default=2, metavar='N',161 help='num of latent variables')162 parser_moe_condnp.add_argument('--experts_in_gates', type=bool, default=False, metavar='N',163 help='whether experts as input for encoders')164 parser_moe_condnp.add_argument('--dim_logit_h', type=int, default=32, metavar='N',165 help='dim of hidden units for encoders') 166 parser_moe_condnp.add_argument('--num_logit_layers', type=int, default=2, metavar='N',167 help='dim of hidden units for encoders') 168 parser_moe_condnp.add_argument('--temperature', type=int, default=0.1, metavar='N') 169 parser_moe_condnp.add_argument('--hard', type=bool, default=False, metavar='N')170 parser_moe_condnp.add_argument('--gumbel_max', type=bool, default=True, metavar='N')171 parser_moe_condnp.add_argument('--info_bottleneck', type=bool, default=False, metavar='N') 172 173 parser_moe_condnp.add_argument('--dim_h', type=int, default=128, metavar='N') 174 parser_moe_condnp.add_argument('--num_h', type=int, default=5, metavar='N') 175 parser_moe_condnp.add_argument('--act_type', type=str, default='ReLU', metavar='N') 176 parser_moe_condnp.add_argument('--amort_y', type=bool, default=False, metavar='N')177 178 args = parser_moe_condnp.parse_args()179 args.cuda = not args.no_cuda and torch.cuda.is_available()180 torch.manual_seed(args.seed)181 random.seed(args.seed)182 device = torch.device("cuda" if args.cuda else "cpu")...
arguments.py
Source:arguments.py
1# Copyright (c) 2018-present, Facebook, Inc.2# All rights reserved.3#4# This source code is licensed under the license found in the5# LICENSE file in the root directory of this source tree.6#7import argparse8def parse_args():9 parser = argparse.ArgumentParser(description='Training script')10 # General arguments11 parser.add_argument('-d', '--dataset', default='h36m', type=str, metavar='NAME', help='target dataset') # h36m or humaneva12 parser.add_argument('-k', '--keypoints', default='cpn_ft_h36m_dbb', type=str, metavar='NAME', help='2D detections to use')13 parser.add_argument('-str', '--subjects-train', default='S1,S5,S6,S7,S8', type=str, metavar='LIST',14 help='training subjects separated by comma')15 parser.add_argument('-ste', '--subjects-test', default='S9,S11', type=str, metavar='LIST', help='test subjects separated by comma')16 parser.add_argument('-sun', '--subjects-unlabeled', default='', type=str, metavar='LIST',17 help='unlabeled subjects separated by comma for self-supervision')18 parser.add_argument('-a', '--actions', default='*', type=str, metavar='LIST',19 help='actions to train/test on, separated by comma, or * for all')20 parser.add_argument('-c', '--checkpoint', default='checkpoint', type=str, metavar='PATH',21 help='checkpoint directory')22 parser.add_argument('--checkpoint-frequency', default=10, type=int, metavar='N',23 help='create a checkpoint every N epochs')24 parser.add_argument('-r', '--resume', default='', type=str, metavar='FILENAME',25 help='checkpoint to resume (file name)')26 parser.add_argument('--evaluate', default='', type=str, metavar='FILENAME', help='checkpoint to evaluate (file name)')27 parser.add_argument('--render', action='store_true', help='visualize a particular video')28 parser.add_argument('--by-subject', action='store_true', help='break down error by subject (on evaluation)')29 parser.add_argument('--export-training-curves', action='store_true', help='save training curves as .png images')30 # Model arguments31 parser.add_argument('-s', '--stride', default=1, type=int, metavar='N', help='chunk size to use during training')32 parser.add_argument('-e', '--epochs', default=60, type=int, metavar='N', help='number of training epochs')33 parser.add_argument('-b', '--batch-size', default=1024, type=int, metavar='N', help='batch size in terms of predicted frames')34 parser.add_argument('-drop', '--dropout', default=0.25, type=float, metavar='P', help='dropout probability')35 parser.add_argument('-lr', '--learning-rate', default=0.001, type=float, metavar='LR', help='initial learning rate')36 parser.add_argument('-lrd', '--lr-decay', default=0.95, type=float, metavar='LR', help='learning rate decay per epoch')37 parser.add_argument('-no-da', '--no-data-augmentation', dest='data_augmentation', action='store_false',38 help='disable train-time flipping')39 parser.add_argument('-no-tta', '--no-test-time-augmentation', dest='test_time_augmentation', action='store_false',40 help='disable test-time flipping')41 parser.add_argument('-arc', '--architecture', default='3,3,3', type=str, metavar='LAYERS', help='filter widths separated by comma')42 parser.add_argument('--causal', action='store_true', help='use causal convolutions for real-time processing')43 parser.add_argument('-ch', '--channels', default=1024, type=int, metavar='N', help='number of channels in convolution layers')44 # Experimental45 parser.add_argument('--subset', default=1, type=float, metavar='FRACTION', help='reduce dataset size by fraction')46 parser.add_argument('--downsample', default=1, type=int, metavar='FACTOR', help='downsample frame rate by factor (semi-supervised)')47 parser.add_argument('--warmup', default=1, type=int, metavar='N', help='warm-up epochs for semi-supervision')48 parser.add_argument('--no-eval', action='store_true', help='disable epoch evaluation while training (small speed-up)')49 parser.add_argument('--dense', action='store_true', help='use dense convolutions instead of dilated convolutions')50 parser.add_argument('--disable-optimizations', action='store_true', help='disable optimized model for single-frame predictions')51 parser.add_argument('--linear-projection', action='store_true', help='use only linear coefficients for semi-supervised projection')52 parser.add_argument('--no-bone-length', action='store_false', dest='bone_length_term',53 help='disable bone length term in semi-supervised settings')54 parser.add_argument('--no-proj', action='store_true', help='disable projection for semi-supervised setting')55 56 # Visualization57 parser.add_argument('--viz-subject', type=str, metavar='STR', help='subject to render')58 parser.add_argument('--viz-action', type=str, metavar='STR', help='action to render')59 parser.add_argument('--viz-camera', type=int, default=0, metavar='N', help='camera to render')60 parser.add_argument('--viz-video', type=str, metavar='PATH', help='path to input video')61 parser.add_argument('--viz-skip', type=int, default=0, metavar='N', help='skip first N frames of input video')62 parser.add_argument('--viz-output', type=str, metavar='PATH', help='output file name (.gif or .mp4)')63 parser.add_argument('--viz-export', type=str, metavar='PATH', help='output file name for coordinates')64 parser.add_argument('--viz-bitrate', type=int, default=3000, metavar='N', help='bitrate for mp4 videos')65 parser.add_argument('--viz-no-ground-truth', action='store_true', help='do not show ground-truth poses')66 parser.add_argument('--viz-limit', type=int, default=-1, metavar='N', help='only render first N frames')67 parser.add_argument('--viz-downsample', type=int, default=1, metavar='N', help='downsample FPS by a factor N')68 parser.add_argument('--viz-size', type=int, default=5, metavar='N', help='image size')69 70 parser.set_defaults(bone_length_term=True)71 parser.set_defaults(data_augmentation=True)72 parser.set_defaults(test_time_augmentation=True)73 74 args = parser.parse_args()75 # Check invalid configuration76 if args.resume and args.evaluate:77 print('Invalid flags: --resume and --evaluate cannot be set at the same time')78 exit()79 80 if args.export_training_curves and args.no_eval:81 print('Invalid flags: --export-training-curves and --no-eval cannot be set at the same time')82 exit()...
generate_parser.py
Source:generate_parser.py
1import argparse2def get_args():3 parser = argparse.ArgumentParser(description='PyTorch Soft Actor-Critic Args')4 parser.add_argument('--env_name', default="HalfCheetah-v2",5 help='Mujoco Gym environment (default: HalfCheetah-v2)')6 parser.add_argument('--policy', default="Gaussian",7 help='Policy Type: Gaussian | Deterministic (default: Gaussian)')8 parser.add_argument('--eval', type=bool, default=True,9 help='Evaluates a policy a policy every 10 episode (default: True)')10 parser.add_argument('--gamma', type=float, default=0.99, metavar='G',11 help='discount factor for reward (default: 0.99)')12 parser.add_argument('--tau', type=float, default=0.005, metavar='G',13 help='target smoothing coefficient(Ï) (default: 0.005)')14 parser.add_argument('--lr', type=float, default=0.0003, metavar='G',15 help='learning rate (default: 0.0003)')16 parser.add_argument('--alpha', type=float, default=0.2, metavar='G',17 help='Temperature parameter α determines the relative importance of the entropy\18 term against the reward (default: 0.2)')19 parser.add_argument('--automatic_entropy_tuning', type=int, default=0, metavar='G',20 help='Automaically adjust α (default: False)')21 parser.add_argument('--seed', type=int, default=123456, metavar='N',22 help='random seed (default: 123456)')23 parser.add_argument('--batch_size', type=int, default=256, metavar='N',24 help='batch size (default: 256)')25 parser.add_argument('--num_steps', type=int, default=1000001, metavar='N',26 help='maximum number of steps (default: 1000000)')27 parser.add_argument('--hidden_size', type=int, default=256, metavar='N',28 help='hidden size (default: 256)')29 parser.add_argument('--updates_per_step', type=int, default=1, metavar='N',30 help='model updates per simulator step (default: 1)')31 parser.add_argument('--start_steps', type=int, default=10000, metavar='N',32 help='Steps sampling random actions (default: 10000)')33 parser.add_argument('--target_update_interval', type=int, default=1, metavar='N',34 help='Value target update per no. of updates per step (default: 1)')35 parser.add_argument('--replay_size', type=int, default=100000, metavar='N', help='size of replay buffer (default: 10000000)')36 parser.add_argument('--cuda', type=int, default=1, metavar='N', help='run on CUDA (default: False)')37 #38 parser.add_argument('--replay_filter_coeff', type=float, default=0.5, metavar='N', help='0. to 1.')39 parser.add_argument('--iter_filter_coeff', type=float, default=0.5, metavar='N', help='0. to inf')40 parser.add_argument('--policy_sampler_type', type=str, default='uniform', metavar='N', help='stratified,uniform,filtered')41 parser.add_argument('--algo', type=str, default='BC', metavar='N', help='stratified,uniform,filtered')42 parser.add_argument('--num_particles', type=int, default=256, metavar='N', help='stratified,uniform,filtered')43 parser.add_argument('--num_clusters', type=int, default=256, metavar='N', help='stratified,uniform,filtered')44 # optimizers stuff45 parser.add_argument('--expert_params_path', type=str, default='models/', metavar='N')46 parser.add_argument('--policy_optim', type=str, default='Adam', metavar='N')47 parser.add_argument('--critic_optim', type=str, default='Adam', metavar='N')48 # sls args49 parser.add_argument('--sls_beta_b', type=float, default=0.9, metavar='N')50 parser.add_argument('--sls_c', type=float, default=0.5, metavar='N')51 parser.add_argument('--sls_gamma', type=float, default=2.0, metavar='N')52 parser.add_argument('--sls_beta_f', type=float, default=2.0, metavar='N')53 parser.add_argument('--log_init_step_size', type=float, default=4., metavar='N')54 parser.add_argument('--sls_eta_max', type=float, default=100., metavar='N')55 # project56 parser.add_argument('--project', type=str, default='optimizers-in-bc', metavar='N')57 parser.add_argument('--group', type=str, default='static-args', metavar='N')58 parser.add_argument('--data_file_location', type=str, default='./data/examples/', metavar='N')59 # BC stuff60 parser.add_argument('--behavior_type', type=str, default='static-args', metavar='N')61 parser.add_argument('--expert_mode', type=int, default=0, metavar='N')62 parser.add_argument('--model_type', type=str, default='nn', metavar='N')63 parser.add_argument('--bandwidth', type=float, default=0., metavar='N')64 # better grid-search65 parser.add_argument('--log_lr', type=float, default=-3., metavar='N')66 parser.add_argument('--log_eps', type=float, default=-5., metavar='N')67 parser.add_argument('--use_log_lr', type=int, default=1, metavar='N')68 parser.add_argument('--transform_dist', type=int, default=1, metavar='N')69 parser.add_argument('--nonlin', type=str, default='relu', metavar='N')70 parser.add_argument('--clamp', type=int, default=0, metavar='N')71 # sps stuff72 parser.add_argument('--use_torch_dataloader', type=int, default=1, metavar='N')73 parser.add_argument('--sps_eps', type=int, default=0, metavar='N')74 parser.add_argument('--batch_in_step', type=int, default=0, metavar='N')75 # world models stuff76 parser.add_argument('--train_world_model', type=int, default=0, metavar='N')77 parser.add_argument('--mpc_algo', type=str, default='WM', metavar='N')78 parser.add_argument('--dyna_optim', type=str, default='Adam', metavar='N')79 parser.add_argument('--log_gan_scale', type=float, default=0., metavar='N')80 parser.add_argument('--marginal_steps', type=int, default=15, metavar='N')81 parser.add_argument('--policy_updates', type=int, default=1, metavar='N')82 parser.add_argument('--dyna_model_type', type=str, default='nn', metavar='N')83 parser.add_argument('--dyna_bandwidth', type=float, default=0., metavar='N')84 # parse85 args, _ = parser.parse_known_args()...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!