2

I have a python code that I want to run from the shell script. This one works

python train.py --dataset './datasets/lausanne' --timestep 30 --obs_len 8 --loader_num_workers 1 --num_epochs 100 --batch_size 16 --embedding_dim 64 --h_dim 32 --num_layers 1 --mlp_dim 64 --dropout 0 --batch_norm 0 --learning_rate 0.0001 --output_dir './models' --print_every 100 --checkpoint_every 100 --checkpoint_name 'cnnlstm' --checkpoint_start_from None --restore_from_checkpoint 1 --use_gpu 1 --gpu_num '0'

But this one doesnt. I just want to split the command into multiple lines.

python train.py \
# Dataset options
--dataset './datasets/lausanne' --timestep 30 --obs_len 8 --loader_num_workers 1 \
# Optimization
--num_epochs 100 --batch_size 16 \
# Model options
--embedding_dim 64 --h_dim 32 --num_layers 1 --mlp_dim 64 --dropout 0 --batch_norm 0 --learning_rate 0.0001 \
# Output
--output_dir './models' --print_every 100 --checkpoint_every 100 --checkpoint_name 'cnnlstm' --checkpoint_start_from None --restore_from_checkpoint 1 \
# Misc
--use_gpu 1 --gpu_num '0'
0

1 Answer 1

4

The comment lines aren't ignored completely; they're treated basically as blank lines.

Putting the script arguments in an array would work better.

args=(
    # Dataset options
    --dataset './datasets/lausanne' --timestep 30 --obs_len 8 --loader_num_workers 1
    # Optimization
    --num_epochs 100 --batch_size 16
    # Model options
    --embedding_dim 64 --h_dim 32 --num_layers 1 --mlp_dim 64 --dropout 0 --batch_norm 0 --learning_rate 0.0001
    # Output
    --output_dir './models' --print_every 100 --checkpoint_every 100 --checkpoint_name 'cnnlstm' --checkpoint_start_from None --restore_from_checkpoint 1
    # Misc
    --use_gpu 1 --gpu_num '0'
    )

python train.py "${args[@]}"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .