Skip to content

Commit dde3a60

Browse files
committed
verify downsampling
1 parent 75fff96 commit dde3a60

File tree

8 files changed

+589
-10
lines changed

8 files changed

+589
-10
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ results/
88
dataset/
99
checkpoints/
1010
testCuda.py
11-
mamba_ssm/wandb/*
11+
*wandb/*

TimeLLM/data_provider/data_loader.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,21 @@ def __init__(self, root_path, flag='train', size=None,
279279
self.freq = freq
280280
self.percent = percent
281281

282+
# New parameters for dynamic downsampling
283+
self.period_of_interest = period_of_interest
284+
print(f"period of interest in dataset_ett_hour: {self.period_of_interest}")
285+
self.timesteps = self.pred_len
286+
282287
self.root_path = root_path
283288
self.data_path = data_path
284289
self.__read_data__()
285290

291+
self.downsampling_factor = calculate_downsampling_factor(self.root_path, self.data_path, self.period_of_interest, self.timesteps)
292+
print("downsampling factor: ", self.downsampling_factor)
293+
self.data_x = self.data_x[::self.downsampling_factor]
294+
self.data_y = self.data_y[::self.downsampling_factor]
295+
self.data_stamp = self.data_stamp[::self.downsampling_factor]
296+
286297
self.enc_in = self.data_x.shape[-1]
287298
self.tot_len = len(self.data_x) - self.seq_len - self.pred_len + 1
288299

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
#!/bin/bash
2+
3+
model_name="TimeLLM"
4+
train_epochs=3
5+
learning_rate=0.01
6+
llm_layers=6
7+
8+
num_params='2.8b'
9+
batch_size=16
10+
d_model=32
11+
d_ff=128
12+
num_process=1 # Ensure this variable is defined
13+
14+
# Function to display usage information
15+
usage() {
16+
echo "Usage: $0 -l <llm_layers> -d <d_model> -e <train_epochs> -n <num_params> -c <save_checkpoints> -m <llm_model> -p <period_of_interest> -g <gpu_id>"
17+
exit 1
18+
}
19+
20+
# Parse command-line arguments
21+
while getopts "l:d:e:n:c:m:p:g:" opt; do
22+
case $opt in
23+
l) llm_layers=$OPTARG ;;
24+
d) d_model=$OPTARG ;;
25+
e) train_epochs=$OPTARG ;;
26+
n) num_params=$OPTARG ;;
27+
c) save_checkpoints=$OPTARG ;;
28+
m) llm_model=$OPTARG ;;
29+
p) period_of_interest=$OPTARG ;;
30+
g) gpu_id=$OPTARG ;;
31+
*) usage ;;
32+
esac
33+
done
34+
35+
# Check if required arguments are provided
36+
if [ -z "$llm_layers" ] || [ -z "$d_model" ] || [ -z "$train_epochs" ] || [ -z "$num_params" ] || [ -z "$save_checkpoints" ] || [ -z "$llm_model" ] || [ -z "$period_of_interest" ] || [ -z "$gpu_id" ]; then
37+
usage
38+
fi
39+
40+
# Export GPU ID and adjust master_port
41+
export CUDA_VISIBLE_DEVICES=$((gpu_id % 4))
42+
master_port_base=01180
43+
master_port="${master_port_base}${gpu_id}"
44+
45+
# Print the values to verify
46+
echo "Setting llm_layers to $llm_layers"
47+
echo "Setting d_model to $d_model"
48+
echo "Setting train_epochs to $train_epochs"
49+
echo "Setting num_params to $num_params"
50+
echo "Setting save_checkpoints to $save_checkpoints"
51+
echo "Setting llm_model to $llm_model"
52+
echo "Setting period_of_interest to $period_of_interest"
53+
echo "Setting master_port to $master_port" # Print master_port for debugging
54+
55+
og_tag="l${llm_layers}_d${d_model}_e${train_epochs}_m${llm_model}_n${num_params}_p${period_of_interest// /_}"
56+
57+
llm_dim=0
58+
if [ "$num_params" = "130m" ]; then
59+
llm_dim=768
60+
fi
61+
if [[ "$num_params" == "2.7b" || "$num_params" == "2.8b" ]]; then
62+
llm_dim=2560
63+
fi
64+
if [ "$num_params" = "7b" ]; then
65+
llm_dim=4096
66+
fi
67+
68+
# Define trials for different pred_len values
69+
for seed in {1..3}; do
70+
tag="ETTh2_${og_tag}_pred${pred_len}_seed${seed}"
71+
comment="checkpoints/${tag}"
72+
log_file="results/${tag}.txt"
73+
exec > "$log_file" 2>&1
74+
75+
accelerate launch --mixed_precision bf16 --num_processes $num_process --main_process_port $master_port seed_process.py \
76+
--task_name long_term_forecast \
77+
--is_training 1 \
78+
--root_path ./dataset/ETT-small/ \
79+
--data_path ETTh2.csv \
80+
--model_id "ETTh2_512_96" \
81+
--model $model_name \
82+
--data ETTh2 \
83+
--features M \
84+
--seq_len 512 \
85+
--label_len 48 \
86+
--pred_len 96 \
87+
--factor 3 \
88+
--enc_in 7 \
89+
--dec_in 7 \
90+
--c_out 7 \
91+
--des 'Exp' \
92+
--itr 1 \
93+
--d_model $d_model \
94+
--d_ff $d_ff \
95+
--batch_size $batch_size \
96+
--learning_rate $learning_rate \
97+
--llm_layers $llm_layers \
98+
--train_epochs $train_epochs \
99+
--model_comment "$comment" \
100+
--llm_model $llm_model \
101+
--llm_dim $llm_dim \
102+
--num_params $num_params \
103+
--period_of_interest "None" \
104+
--seed $seed
105+
106+
echo "ETTh2 with seed $seed completed, saved to $comment"
107+
done
108+

TimeLLM/scripts/clean_combine.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ if [ "$num_params" = "7b" ]; then
6666
fi
6767

6868
# Define trials for different pred_len values
69-
for pred_len in 48 64; do
70-
for seed in {1..10}; do
69+
for pred_len in 64; do
70+
for seed in {1..3}; do
7171
tag="ETTh1_${og_tag}_pred${pred_len}_seed${seed}"
7272
comment="checkpoints/${tag}"
7373
log_file="results/${tag}.txt"

TimeLLM/scripts/combineGPU2.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ done
105105
'
106106

107107
tag="ETTm1_${og_tag}"
108-
for seed in {3..10}; do
108+
for seed in {1..10}; do
109109
comment="checkpoints/${tag}_seed${seed}"
110110
log_file="results/${tag}_seed${seed}.txt"
111111
exec > "$log_file" 2>&1

TimeLLM/scripts/smalltest.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ d_ff=128
1212
comment='checkpoints/smallTest'
1313
gpu_id=3
1414
export CUDA_VISIBLE_DEVICES=$gpu_id
15-
15+
: '
1616
accelerate launch --mixed_precision bf16 --num_processes $num_process --main_process_port $master_port seed_process.py \
1717
--task_name long_term_forecast \
1818
--is_training 1 \
@@ -40,9 +40,10 @@ export CUDA_VISIBLE_DEVICES=$gpu_id
4040
--model_comment "$comment" \
4141
--llm_model Mamba2 \
4242
--llm_dim 768 \
43-
--period_of_interest "1 month" \
43+
--period_of_interest "None" \
4444
--use_wandb 0
45-
: '
45+
'
46+
4647
accelerate launch --mixed_precision bf16 --num_processes 1 --gpu_ids $gpu_id --main_process_port $master_port seed_process.py \
4748
--task_name long_term_forecast \
4849
--is_training 1 \
@@ -52,9 +53,9 @@ accelerate launch --mixed_precision bf16 --num_processes 1 --gpu_ids $gpu_id --m
5253
--model $model_name \
5354
--data Traffic \
5455
--features M \
55-
--seq_len 512 \
56+
--seq_len 96 \
5657
--label_len 48 \
57-
--pred_len 96 \
58+
--pred_len 128\
5859
--e_layers 2 \
5960
--d_layers 1 \
6061
--factor 3 \
@@ -72,7 +73,7 @@ accelerate launch --mixed_precision bf16 --num_processes 1 --gpu_ids $gpu_id --m
7273
--period_of_interest "1 month" \
7374
--use_wandb 0
7475

75-
76+
: '
7677
accelerate launch --mixed_precision bf16 --num_processes 1 --gpu_ids $gpu_id --main_process_port $master_port seed_process.py \
7778
--task_name long_term_forecast \
7879
--is_training 1 \

TimeLLM/scripts/traffic_combine.sh

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
#!/bin/bash
2+
3+
model_name="TimeLLM"
4+
train_epochs=3
5+
learning_rate=0.01
6+
llm_layers=6
7+
8+
num_params='2.8b'
9+
batch_size=16
10+
d_model=32
11+
d_ff=128
12+
num_process=1 # Ensure this variable is defined
13+
14+
# Function to display usage information
15+
usage() {
16+
echo "Usage: $0 -l <llm_layers> -d <d_model> -e <train_epochs> -n <num_params> -c <save_checkpoints> -m <llm_model> -p <period_of_interest> -g <gpu_id>"
17+
exit 1
18+
}
19+
20+
# Parse command-line arguments
21+
while getopts "l:d:e:n:c:m:p:g:" opt; do
22+
case $opt in
23+
l) llm_layers=$OPTARG ;;
24+
d) d_model=$OPTARG ;;
25+
e) train_epochs=$OPTARG ;;
26+
n) num_params=$OPTARG ;;
27+
c) save_checkpoints=$OPTARG ;;
28+
m) llm_model=$OPTARG ;;
29+
p) period_of_interest=$OPTARG ;;
30+
g) gpu_id=$OPTARG ;;
31+
*) usage ;;
32+
esac
33+
done
34+
35+
# Check if required arguments are provided
36+
if [ -z "$llm_layers" ] || [ -z "$d_model" ] || [ -z "$train_epochs" ] || [ -z "$num_params" ] || [ -z "$save_checkpoints" ] || [ -z "$llm_model" ] || [ -z "$period_of_interest" ] || [ -z "$gpu_id" ]; then
37+
usage
38+
fi
39+
40+
# Export GPU ID and adjust master_port
41+
export CUDA_VISIBLE_DEVICES=$((gpu_id % 4))
42+
master_port_base=01180
43+
master_port="${master_port_base}${gpu_id}"
44+
45+
# Print the values to verify
46+
echo "Setting llm_layers to $llm_layers"
47+
echo "Setting d_model to $d_model"
48+
echo "Setting train_epochs to $train_epochs"
49+
echo "Setting num_params to $num_params"
50+
echo "Setting save_checkpoints to $save_checkpoints"
51+
echo "Setting llm_model to $llm_model"
52+
echo "Setting period_of_interest to $period_of_interest"
53+
echo "Setting master_port to $master_port" # Print master_port for debugging
54+
55+
og_tag="l${llm_layers}_d${d_model}_e${train_epochs}_m${llm_model}_n${num_params}_p${period_of_interest// /_}"
56+
57+
llm_dim=0
58+
if [ "$num_params" = "130m" ]; then
59+
llm_dim=768
60+
fi
61+
if [[ "$num_params" == "2.7b" || "$num_params" == "2.8b" ]]; then
62+
llm_dim=2560
63+
fi
64+
if [ "$num_params" = "7b" ]; then
65+
llm_dim=4096
66+
fi
67+
68+
# Define trials for different pred_len values
69+
for pred_len in 96 128; do
70+
for seed in {1..3}; do
71+
tag="Traffic_${og_tag}_pred${pred_len}_seed${seed}"
72+
comment="checkpoints/${tag}"
73+
log_file="results/${tag}.txt"
74+
exec > "$log_file" 2>&1
75+
76+
accelerate launch --mixed_precision bf16 --num_processes 1 --gpu_ids $gpu_id --main_process_port $master_port seed_process.py \
77+
--task_name long_term_forecast \
78+
--is_training 1 \
79+
--root_path ./dataset/traffic/ \
80+
--data_path traffic.csv \
81+
--model_id "traffic_96_${pred_len}" \
82+
--model $model_name \
83+
--data Traffic \
84+
--features M \
85+
--seq_len 96 \
86+
--label_len 24 \
87+
--pred_len $pred_len \
88+
--factor 3 \
89+
--enc_in 7 \
90+
--dec_in 7 \
91+
--c_out 7 \
92+
--des 'Exp' \
93+
--itr 1 \
94+
--d_model $d_model \
95+
--d_ff $d_ff \
96+
--batch_size $batch_size \
97+
--learning_rate $learning_rate \
98+
--llm_layers $llm_layers \
99+
--train_epochs $train_epochs \
100+
--model_comment "$comment" \
101+
--llm_model $llm_model \
102+
--llm_dim $llm_dim \
103+
--num_params $num_params \
104+
--period_of_interest "$period_of_interest" \
105+
--seed $seed
106+
107+
echo "ETTh1 with pred_len $pred_len and seed $seed completed, saved to $comment"
108+
done
109+
done

0 commit comments

Comments
 (0)