mirror of
https://github.com/wassname/DeepTime.git
synced 2026-07-20 12:10:30 +08:00
partially converted to M2S (multi inputs)
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
build.experiment_name = 'Stocks/96M2S'
|
||||
build.module = 'experiments.forecast'
|
||||
build.repeat = 1
|
||||
build.variables_dict = {
|
||||
}
|
||||
|
||||
instance.model_type = 'deeptime3'
|
||||
instance.save_vals = False
|
||||
|
||||
get_optimizer.lr = 1e-3
|
||||
get_optimizer.lambda_lr = 1.
|
||||
get_optimizer.weight_decay = 0.
|
||||
|
||||
get_scheduler.warmup_epochs = 5
|
||||
|
||||
get_data.batch_size = 256
|
||||
|
||||
train.loss_name = 'mse'
|
||||
train.epochs = 50
|
||||
train.clip = 10.
|
||||
|
||||
Checkpoint.patience = 7
|
||||
|
||||
deeptime3.layer_size = 32
|
||||
deeptime3.inr_layers = 5
|
||||
deeptime3.n_fourier_feats = 4096
|
||||
deeptime3.scales = [0.01, 0.1, 1, 5, 10, 20, 50, 100]
|
||||
|
||||
ForecastDataset.data_path = 'stocks/OXY_2019.csv.gz'
|
||||
ForecastDataset.target = 'RSMKs_18_144_72'
|
||||
ForecastDataset.scale = True
|
||||
ForecastDataset.cross_learn = False
|
||||
ForecastDataset.time_features = []
|
||||
ForecastDataset.normalise_time_features = True
|
||||
ForecastDataset.features = 'M2S'
|
||||
ForecastDataset.horizon_len = 96
|
||||
ForecastDataset.lookback_mult = 1
|
||||
+13
-12
@@ -139,16 +139,16 @@ def train(model: nn.Module,
|
||||
model.train()
|
||||
for it, data in enumerate(train_loader):
|
||||
optimizer.zero_grad()
|
||||
|
||||
x, y, x_time, y_time = map(to_tensor, data)
|
||||
forecast = model(x, x_time, y_time)
|
||||
data2 = list(map(to_tensor, data))
|
||||
context_past_x, context_y, query_past_x, query_y, context_time, query_time = data2
|
||||
forecast = model(*data2)
|
||||
|
||||
if isinstance(forecast, tuple):
|
||||
# for models which require reconstruction + forecast loss
|
||||
loss = training_loss_fn(forecast[0], x) + \
|
||||
training_loss_fn(forecast[1], y)
|
||||
loss = training_loss_fn(forecast[0], context_y) + \
|
||||
training_loss_fn(forecast[1], query_y)
|
||||
else:
|
||||
loss = training_loss_fn(forecast, y)
|
||||
loss = training_loss_fn(forecast, query_y)
|
||||
loss.backward()
|
||||
nn.utils.clip_grad_norm_(model.parameters(), clip)
|
||||
optimizer.step()
|
||||
@@ -188,22 +188,23 @@ def validate(model: nn.Module,
|
||||
inps = []
|
||||
total_loss = []
|
||||
for it, data in enumerate(loader):
|
||||
x, y, x_time, y_time = map(to_tensor, data)
|
||||
data2 = list(map(to_tensor, data))
|
||||
context_past_x, context_y, query_past_x, query_y, context_time, query_time = data2
|
||||
|
||||
if x.shape[0] == 1:
|
||||
if context_past_x.shape[0] == 1:
|
||||
# skip final batch if batch_size == 1
|
||||
# due to bug in torch.linalg.solve which raises error when batch_size == 1
|
||||
continue
|
||||
|
||||
forecast = model(x, x_time, y_time)
|
||||
forecast = model(*data2)
|
||||
|
||||
if report_metrics:
|
||||
preds.append(forecast)
|
||||
trues.append(y)
|
||||
trues.append(query_y)
|
||||
if save_path is not None:
|
||||
inps.append(x)
|
||||
inps.append(context_y)
|
||||
else:
|
||||
loss = loss_fn(forecast, y, reduction='none')
|
||||
loss = loss_fn(forecast, query_y, reduction='none')
|
||||
total_loss.append(loss)
|
||||
|
||||
if report_metrics:
|
||||
|
||||
Reference in New Issue
Block a user