Skip to content

Commit

Permalink
Chronos: set kernel of Autoformer to odd number (intel-analytics#5534)
Browse files Browse the repository at this point in the history
* set kernel to odd
  • Loading branch information
rnwang04 authored and ForJadeForest committed Sep 20, 2022
1 parent f17f3dd commit e4aa294
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ def __init__(self, configs):
self.loss = loss_creator(configs.loss)

# Decomp
kernel_size = configs.moving_avg
# change kernei_size to odd
kernel_size = int(2 * (configs.moving_avg // 2)) + 1
self.decomp = series_decomp(kernel_size)

# Embedding
Expand All @@ -93,7 +94,7 @@ def __init__(self, configs):
configs.d_model, configs.n_heads),
configs.d_model,
configs.d_ff,
moving_avg=configs.moving_avg,
moving_avg=kernel_size,
dropout=configs.dropout,
activation=configs.activation
) for l in range(configs.e_layers)
Expand All @@ -115,7 +116,7 @@ def __init__(self, configs):
configs.d_model,
configs.c_out,
configs.d_ff,
moving_avg=configs.moving_avg,
moving_avg=kernel_size,
dropout=configs.dropout,
activation=configs.activation,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,3 +224,19 @@ def test_autoformer_forecaster_tune_save_load(self):
forecaster.load(ckpt_name)
evaluate2 = forecaster.evaluate(val_data)
assert evaluate1[0]['val/loss'] == evaluate2[0]['val_loss']

def test_autoformer_forecaster_even_kernel(self):
train_loader, val_loader, test_loader = create_data(loader=True)
evaluate_list = []
forecaster = AutoformerForecaster(past_seq_len=24,
future_seq_len=5,
input_feature_num=2,
output_feature_num=2,
label_len=12,
freq='s',
seed=0,
moving_avg=20) # even
forecaster.fit(train_loader, epochs=3, batch_size=32)
evaluate = forecaster.evaluate(val_loader)
pred = forecaster.predict(test_loader)
evaluate_list.append(evaluate)

0 comments on commit e4aa294

Please sign in to comment.