| #!/bin/bash |
| |
| |
| |
| |
| |
| set -euo pipefail |
|
|
| REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" |
| cd "${REPO_ROOT}" |
|
|
| DATA_ROOT="${REPO_ROOT}/experiments/datasets/mimicgen/" |
| RUN_ROOT="${REPO_ROOT}/experiments/pretrain_runs/" |
| CONFIG="configs/xmagical/pretraining/tcc.py" |
| DEVICE="${DEVICE:-cuda:0}" |
| FRESH="${FRESH:-0}" |
| TASKS=("lift" "stack") |
|
|
| for task in "${TASKS[@]}"; do |
| EXP_NAME="dataset=mimicgen_algo=xirl_task=${task}" |
| EXP_DIR="${RUN_ROOT}/${EXP_NAME}" |
| RESUME_FLAG=() |
|
|
| if [[ "${FRESH}" == "1" && -d "${EXP_DIR}" ]]; then |
| echo "FRESH=1: removing existing run ${EXP_DIR}" |
| rm -rf "${EXP_DIR}" |
| elif [[ -d "${EXP_DIR}" ]]; then |
| echo "Existing run found for ${task}; resuming from checkpoint." |
| RESUME_FLAG=(--resume) |
| fi |
|
|
| echo "========================================" |
| echo "Pretraining task: ${task}" |
| echo "========================================" |
|
|
| python pretrain.py \ |
| --experiment_name="${EXP_NAME}" \ |
| --config="${CONFIG}" \ |
| --config.data.root="${DATA_ROOT}" \ |
| --config.root_dir="${RUN_ROOT}" \ |
| --config.data.pretrain_action_class="('${task}',)" \ |
| --config.data.downstream_action_class="('${task}',)" \ |
| --config.data.max_vids_per_class=-1 \ |
| --device="${DEVICE}" \ |
| "${RESUME_FLAG[@]}" |
|
|
| echo "Exporting goal/subgoal embeddings for ${task}..." |
| python compute_subgoal_embedding.py \ |
| --experiment_path="${EXP_DIR}" |
|
|
| echo "Finished ${task}." |
| echo " checkpoints: ${EXP_DIR}/checkpoints/" |
| echo " subgoals: ${EXP_DIR}/subgoals_emb.pkl" |
| done |
|
|
| echo "All tasks finished." |
|
|