mirror of
https://github.com/wassname/DeepTime.git
synced 2026-08-20 12:00:07 +08:00
56 KiB
56 KiB
In [1]:
import warnings
warnings.simplefilter("ignore")
# autoreload import your package
%load_ext autoreload
%autoreload 2In [2]:
import os
from os.path import join
import math
import logging
from typing import Callable, Optional, Union, Dict, Tuple
from matplotlib import pyplot as plt
from pathlib import Path
import matplotlib.colors as mcolors
import gin
from fire import Fire
import numpy as np
import torch
from torch.utils.data import DataLoader
from torch import optim
from torch import nn
from experiments.base import Experiment
from data.datasets import ForecastDataset
from models import get_model
from utils.checkpoint import Checkpoint
from utils.ops import default_device, to_tensor
from utils.losses import get_loss_fn
from utils.metrics import calc_metrics
from experiments.forecast import get_data
gin.enter_interactive_mode()In [ ]:
In [3]:
def plot(model_name="deeptime", save_path=Path("storage/experiments/Exchange/96M/repeat=0"), i=200, title=None, plot=True):
gin.clear_config()
gin.parse_config(open(save_path/"config.gin"))
train_set, train_loader = get_data(flag='train', batch_size=2)
model = get_model(model_name,
dim_size=train_set.data_x.shape[1],
datetime_feats=train_set.timestamps.shape[-1]).to(default_device())
model.load_state_dict(torch.load(save_path/'model.pth'))
model = model.eval()
b = train_set[i]
b = [bb[None, :] for bb in b]
x, y, x_time, y_time = map(to_tensor, b)
with torch.no_grad():
forecast = model(x, x_time, y_time)
if title is None:
title = str(save_path).split('/')[-3:]
title = "-".join(title)
colors = list(mcolors.BASE_COLORS.keys())
l = x.shape[1]
forecast2 = forecast[0].detach().cpu().numpy()
x2 = x[0].cpu()
y2 = y[0].cpu()
l2 = y.shape[1]
i_past = list(range(l))
i_future = list(range(l, l+l2))
if plot:
plt.title(title)
for i in range(x.shape[-1]):
plt.plot(i_past, x2[:, i], c=colors[i])
for i in range(x.shape[-1]):
plt.plot(i_future, y2[:, i], c=colors[i])
for i in range(x.shape[-1]):
plt.plot(i_future, forecast2[:, i], c=colors[i], linestyle='--')
return x2, y2, forecast2, i_past, i_future
In [4]:
def plot_multi(save_paths=[Path("storage/experiments/Exchange/96M/repeat=0")], i=200, title=None, plot=True):
for j in range(len(save_paths)):
save_path = save_paths[j]
gin.clear_config()
gin.parse_config(open(save_path/"config.gin"))
model_name = gin.query_parameter("instance.model_type")
train_set, train_loader = get_data(flag='test', batch_size=3)
model = get_model(model_name,
dim_size=train_set.data_x.shape[1],
datetime_feats=train_set.timestamps.shape[-1]).to(default_device())
model.load_state_dict(torch.load(save_path/'model.pth'))
model = model.eval()
b = train_set[i]
b = [bb[None, :] for bb in b]
b = next(iter(train_loader))
print([s.shape for s in b])
x, y, x_time, y_time = map(to_tensor, b)
# print(b)
with torch.no_grad():
forecast = model(x, x_time, y_time)
colors = list(mcolors.BASE_COLORS.keys())
l = x.shape[1]
forecast2 = forecast[0].detach().cpu().numpy()
x2 = x[0].cpu()
y2 = y[0].cpu()
l2 = y.shape[1]
i_past = list(range(l))
i_future = list(range(l, l+l2))
if plot:
plt.plot(i_past, x2[:, 0], c=colors[0], label=f"past")
plt.plot(i_future, y2[:, 0], c=colors[0], label="future true", alpha=0.3)
mtitle = str(save_path).split('/')[-2:-1]
mtitle = "-".join(mtitle)
plt.plot(i_future, forecast2[:, 0], c=colors[j], linestyle='--', label=f"{mtitle}")
plt.legend()
plt.title(title)
return x2, y2, forecast2, i_past, i_future
In [5]:
# list the models we have run...
m=sorted(Path("storage/experiments/Stocks").glob("**/_SUCCESS"))
print(m)[Path('storage/experiments/Stocks/96M/repeat=0/_SUCCESS'), Path('storage/experiments/Stocks/96S/repeat=0/_SUCCESS'), Path('storage/experiments/Stocks/96Splus/repeat=0/_SUCCESS'), Path('storage/experiments/Stocks/96Splusshort/repeat=0/_SUCCESS'), Path('storage/experiments/Stocks/96Sshort/repeat=0/_SUCCESS')]
In [6]:
save_path = Path('storage/experiments/Stocks/96M2S/repeat=0')In [7]:
gin.clear_config()
config_path = save_path/"config.gin"
gin.parse_config(open(config_path))
model_name = gin.query_parameter("instance.model_type")
model_nameOut [7]:
'deeptime3'
In [8]:
from experiments.forecast import ForecastExperiment
exp = ForecastExperiment(config_path=config_path)
expOut [8]:
<experiments.forecast.ForecastExperiment at 0x7f4044fc3fa0>
In [9]:
exp.run()receptive field [114 72 12]=[38 18 2]*[[1 1 1] [1 1 1] [1 2 4]] 129 in_feats receptive field [690 378 242]=[138 18 2]*[[ 1 1 1] [ 1 2 4] [ 1 4 16] [ 1 6 36] [ 1 8 64]] torch.Size([256, 96, 129]) torch.Size([256, 96, 129])
[0;31m---------------------------------------------------------------------------[0m
[0;31mRuntimeError[0m Traceback (most recent call last)
Cell [0;32mIn [9], line 1[0m
[0;32m----> 1[0m [43mexp[49m[38;5;241;43m.[39;49m[43mrun[49m[43m([49m[43m)[49m
File [0;32m~/miniforge3/envs/deeptime/lib/python3.8/site-packages/gin/config.py:1605[0m, in [0;36m_make_gin_wrapper.<locals>.gin_wrapper[0;34m(*args, **kwargs)[0m
[1;32m 1603[0m scope_info [38;5;241m=[39m [38;5;124m"[39m[38;5;124m in scope [39m[38;5;124m'[39m[38;5;132;01m{}[39;00m[38;5;124m'[39m[38;5;124m"[39m[38;5;241m.[39mformat(scope_str) [38;5;28;01mif[39;00m scope_str [38;5;28;01melse[39;00m [38;5;124m'[39m[38;5;124m'[39m
[1;32m 1604[0m err_str [38;5;241m=[39m err_str[38;5;241m.[39mformat(name, fn_or_cls, scope_info)
[0;32m-> 1605[0m [43mutils[49m[38;5;241;43m.[39;49m[43maugment_exception_message_and_reraise[49m[43m([49m[43me[49m[43m,[49m[43m [49m[43merr_str[49m[43m)[49m
File [0;32m~/miniforge3/envs/deeptime/lib/python3.8/site-packages/gin/utils.py:41[0m, in [0;36maugment_exception_message_and_reraise[0;34m(exception, message)[0m
[1;32m 39[0m proxy [38;5;241m=[39m ExceptionProxy()
[1;32m 40[0m ExceptionProxy[38;5;241m.[39m[38;5;18m__qualname__[39m [38;5;241m=[39m [38;5;28mtype[39m(exception)[38;5;241m.[39m[38;5;18m__qualname__[39m
[0;32m---> 41[0m [38;5;28;01mraise[39;00m proxy[38;5;241m.[39mwith_traceback(exception[38;5;241m.[39m__traceback__) [38;5;28;01mfrom[39;00m [38;5;28mNone[39m
File [0;32m~/miniforge3/envs/deeptime/lib/python3.8/site-packages/gin/config.py:1582[0m, in [0;36m_make_gin_wrapper.<locals>.gin_wrapper[0;34m(*args, **kwargs)[0m
[1;32m 1579[0m new_kwargs[38;5;241m.[39mupdate(kwargs)
[1;32m 1581[0m [38;5;28;01mtry[39;00m:
[0;32m-> 1582[0m [38;5;28;01mreturn[39;00m [43mfn[49m[43m([49m[38;5;241;43m*[39;49m[43mnew_args[49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mnew_kwargs[49m[43m)[49m
[1;32m 1583[0m [38;5;28;01mexcept[39;00m [38;5;167;01mException[39;00m [38;5;28;01mas[39;00m e: [38;5;66;03m# pylint: disable=broad-except[39;00m
[1;32m 1584[0m err_str [38;5;241m=[39m [38;5;124m'[39m[38;5;124m'[39m
File [0;32m/media/wassname/SGIronWolf/projects5/investing/DeepTime/experiments/base.py:96[0m, in [0;36mExperiment.run[0;34m(self, timer)[0m
[1;32m 94[0m [38;5;28;01mexcept[39;00m [38;5;167;01mException[39;00m [38;5;28;01mas[39;00m e:
[1;32m 95[0m Path(running_flag)[38;5;241m.[39munlink()
[0;32m---> 96[0m [38;5;28;01mraise[39;00m e
[1;32m 97[0m [38;5;28;01mexcept[39;00m [38;5;167;01mKeyboardInterrupt[39;00m:
[1;32m 98[0m Path(running_flag)[38;5;241m.[39munlink()
File [0;32m/media/wassname/SGIronWolf/projects5/investing/DeepTime/experiments/base.py:93[0m, in [0;36mExperiment.run[0;34m(self, timer)[0m
[1;32m 90[0m Path(running_flag)[38;5;241m.[39mtouch()
[1;32m 92[0m [38;5;28;01mtry[39;00m:
[0;32m---> 93[0m [38;5;28;43mself[39;49m[38;5;241;43m.[39;49m[43minstance[49m[43m([49m[43m)[49m
[1;32m 94[0m [38;5;28;01mexcept[39;00m [38;5;167;01mException[39;00m [38;5;28;01mas[39;00m e:
[1;32m 95[0m Path(running_flag)[38;5;241m.[39munlink()
File [0;32m~/miniforge3/envs/deeptime/lib/python3.8/site-packages/gin/config.py:1605[0m, in [0;36m_make_gin_wrapper.<locals>.gin_wrapper[0;34m(*args, **kwargs)[0m
[1;32m 1603[0m scope_info [38;5;241m=[39m [38;5;124m"[39m[38;5;124m in scope [39m[38;5;124m'[39m[38;5;132;01m{}[39;00m[38;5;124m'[39m[38;5;124m"[39m[38;5;241m.[39mformat(scope_str) [38;5;28;01mif[39;00m scope_str [38;5;28;01melse[39;00m [38;5;124m'[39m[38;5;124m'[39m
[1;32m 1604[0m err_str [38;5;241m=[39m err_str[38;5;241m.[39mformat(name, fn_or_cls, scope_info)
[0;32m-> 1605[0m [43mutils[49m[38;5;241;43m.[39;49m[43maugment_exception_message_and_reraise[49m[43m([49m[43me[49m[43m,[49m[43m [49m[43merr_str[49m[43m)[49m
File [0;32m~/miniforge3/envs/deeptime/lib/python3.8/site-packages/gin/utils.py:41[0m, in [0;36maugment_exception_message_and_reraise[0;34m(exception, message)[0m
[1;32m 39[0m proxy [38;5;241m=[39m ExceptionProxy()
[1;32m 40[0m ExceptionProxy[38;5;241m.[39m[38;5;18m__qualname__[39m [38;5;241m=[39m [38;5;28mtype[39m(exception)[38;5;241m.[39m[38;5;18m__qualname__[39m
[0;32m---> 41[0m [38;5;28;01mraise[39;00m proxy[38;5;241m.[39mwith_traceback(exception[38;5;241m.[39m__traceback__) [38;5;28;01mfrom[39;00m [38;5;28mNone[39m
File [0;32m~/miniforge3/envs/deeptime/lib/python3.8/site-packages/gin/config.py:1582[0m, in [0;36m_make_gin_wrapper.<locals>.gin_wrapper[0;34m(*args, **kwargs)[0m
[1;32m 1579[0m new_kwargs[38;5;241m.[39mupdate(kwargs)
[1;32m 1581[0m [38;5;28;01mtry[39;00m:
[0;32m-> 1582[0m [38;5;28;01mreturn[39;00m [43mfn[49m[43m([49m[38;5;241;43m*[39;49m[43mnew_args[49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mnew_kwargs[49m[43m)[49m
[1;32m 1583[0m [38;5;28;01mexcept[39;00m [38;5;167;01mException[39;00m [38;5;28;01mas[39;00m e: [38;5;66;03m# pylint: disable=broad-except[39;00m
[1;32m 1584[0m err_str [38;5;241m=[39m [38;5;124m'[39m[38;5;124m'[39m
File [0;32m/media/wassname/SGIronWolf/projects5/investing/DeepTime/experiments/forecast.py:40[0m, in [0;36mForecastExperiment.instance[0;34m(self, model_type, save_vals)[0m
[1;32m 37[0m checkpoint [38;5;241m=[39m Checkpoint([38;5;28mself[39m[38;5;241m.[39mroot)
[1;32m 39[0m [38;5;66;03m# train forecasting task[39;00m
[0;32m---> 40[0m model [38;5;241m=[39m [43mtrain[49m[43m([49m[43mmodel[49m[43m,[49m[43m [49m[43mcheckpoint[49m[43m,[49m[43m [49m[43mtrain_loader[49m[43m,[49m[43m [49m[43mval_loader[49m[43m,[49m[43m [49m[43mtest_loader[49m[43m)[49m
[1;32m 42[0m [38;5;66;03m# testing[39;00m
[1;32m 43[0m val_metrics [38;5;241m=[39m validate(model, loader[38;5;241m=[39mval_loader, report_metrics[38;5;241m=[39m[38;5;28;01mTrue[39;00m)
File [0;32m~/miniforge3/envs/deeptime/lib/python3.8/site-packages/gin/config.py:1605[0m, in [0;36m_make_gin_wrapper.<locals>.gin_wrapper[0;34m(*args, **kwargs)[0m
[1;32m 1603[0m scope_info [38;5;241m=[39m [38;5;124m"[39m[38;5;124m in scope [39m[38;5;124m'[39m[38;5;132;01m{}[39;00m[38;5;124m'[39m[38;5;124m"[39m[38;5;241m.[39mformat(scope_str) [38;5;28;01mif[39;00m scope_str [38;5;28;01melse[39;00m [38;5;124m'[39m[38;5;124m'[39m
[1;32m 1604[0m err_str [38;5;241m=[39m err_str[38;5;241m.[39mformat(name, fn_or_cls, scope_info)
[0;32m-> 1605[0m [43mutils[49m[38;5;241;43m.[39;49m[43maugment_exception_message_and_reraise[49m[43m([49m[43me[49m[43m,[49m[43m [49m[43merr_str[49m[43m)[49m
File [0;32m~/miniforge3/envs/deeptime/lib/python3.8/site-packages/gin/utils.py:41[0m, in [0;36maugment_exception_message_and_reraise[0;34m(exception, message)[0m
[1;32m 39[0m proxy [38;5;241m=[39m ExceptionProxy()
[1;32m 40[0m ExceptionProxy[38;5;241m.[39m[38;5;18m__qualname__[39m [38;5;241m=[39m [38;5;28mtype[39m(exception)[38;5;241m.[39m[38;5;18m__qualname__[39m
[0;32m---> 41[0m [38;5;28;01mraise[39;00m proxy[38;5;241m.[39mwith_traceback(exception[38;5;241m.[39m__traceback__) [38;5;28;01mfrom[39;00m [38;5;28mNone[39m
File [0;32m~/miniforge3/envs/deeptime/lib/python3.8/site-packages/gin/config.py:1582[0m, in [0;36m_make_gin_wrapper.<locals>.gin_wrapper[0;34m(*args, **kwargs)[0m
[1;32m 1579[0m new_kwargs[38;5;241m.[39mupdate(kwargs)
[1;32m 1581[0m [38;5;28;01mtry[39;00m:
[0;32m-> 1582[0m [38;5;28;01mreturn[39;00m [43mfn[49m[43m([49m[38;5;241;43m*[39;49m[43mnew_args[49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mnew_kwargs[49m[43m)[49m
[1;32m 1583[0m [38;5;28;01mexcept[39;00m [38;5;167;01mException[39;00m [38;5;28;01mas[39;00m e: [38;5;66;03m# pylint: disable=broad-except[39;00m
[1;32m 1584[0m err_str [38;5;241m=[39m [38;5;124m'[39m[38;5;124m'[39m
File [0;32m/media/wassname/SGIronWolf/projects5/investing/DeepTime/experiments/forecast.py:144[0m, in [0;36mtrain[0;34m(model, checkpoint, train_loader, val_loader, test_loader, loss_name, epochs, clip)[0m
[1;32m 142[0m data2 [38;5;241m=[39m [38;5;28mmap[39m(to_tensor, data)
[1;32m 143[0m context_past_x, context_y, query_past_x, query_y, context_time, query_time [38;5;241m=[39m data2
[0;32m--> 144[0m forecast [38;5;241m=[39m [43mmodel[49m[43m([49m[43mcontext_past_x[49m[43m,[49m[43m [49m[43mcontext_y[49m[43m,[49m[43m [49m[43mquery_past_x[49m[43m,[49m[43m [49m[43mcontext_time[49m[43m,[49m[43m [49m[43mquery_time[49m[43m)[49m
[1;32m 146[0m [38;5;28;01mif[39;00m [38;5;28misinstance[39m(forecast, [38;5;28mtuple[39m):
[1;32m 147[0m [38;5;66;03m# for models which require reconstruction + forecast loss[39;00m
[1;32m 148[0m loss [38;5;241m=[39m training_loss_fn(forecast[[38;5;241m0[39m], context_y) [38;5;241m+[39m \
[1;32m 149[0m training_loss_fn(forecast[[38;5;241m1[39m], query_y)
File [0;32m~/miniforge3/envs/deeptime/lib/python3.8/site-packages/torch/nn/modules/module.py:1102[0m, in [0;36mModule._call_impl[0;34m(self, *input, **kwargs)[0m
[1;32m 1098[0m [38;5;66;03m# If we don't have any hooks, we want to skip the rest of the logic in[39;00m
[1;32m 1099[0m [38;5;66;03m# this function, and just call forward.[39;00m
[1;32m 1100[0m [38;5;28;01mif[39;00m [38;5;129;01mnot[39;00m ([38;5;28mself[39m[38;5;241m.[39m_backward_hooks [38;5;129;01mor[39;00m [38;5;28mself[39m[38;5;241m.[39m_forward_hooks [38;5;129;01mor[39;00m [38;5;28mself[39m[38;5;241m.[39m_forward_pre_hooks [38;5;129;01mor[39;00m _global_backward_hooks
[1;32m 1101[0m [38;5;129;01mor[39;00m _global_forward_hooks [38;5;129;01mor[39;00m _global_forward_pre_hooks):
[0;32m-> 1102[0m [38;5;28;01mreturn[39;00m [43mforward_call[49m[43m([49m[38;5;241;43m*[39;49m[38;5;28;43minput[39;49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mkwargs[49m[43m)[49m
[1;32m 1103[0m [38;5;66;03m# Do not call functions when jit is used[39;00m
[1;32m 1104[0m full_backward_hooks, non_full_backward_hooks [38;5;241m=[39m [], []
File [0;32m/media/wassname/SGIronWolf/projects5/investing/DeepTime/models/DeepTIMe3.py:77[0m, in [0;36mDeepTIMe3.forward[0;34m(self, context_past_x, context_y, query_past_x, context_time, query_time)[0m
[1;32m 74[0m [38;5;28;01mdef[39;00m [38;5;21mforward[39m([38;5;28mself[39m, context_past_x, context_y, query_past_x, context_time, query_time) [38;5;241m-[39m[38;5;241m>[39m Tensor:
[1;32m 76[0m context_reprs [38;5;241m=[39m [38;5;28mself[39m[38;5;241m.[39mencode_and_decode(context_past_x, context_time)
[0;32m---> 77[0m query_reprs [38;5;241m=[39m [38;5;28;43mself[39;49m[38;5;241;43m.[39;49m[43mencode_and_decode[49m[43m([49m[43mquery_past_x[49m[43m,[49m[43m [49m[43mquery_time[49m[43m,[49m[43m [49m[43moffset[49m[38;5;241;43m=[39;49m[43mcontext_reprs[49m[38;5;241;43m.[39;49m[43mshape[49m[43m[[49m[38;5;241;43m1[39;49m[43m][49m[43m)[49m
[1;32m 79[0m w, b [38;5;241m=[39m [38;5;28mself[39m[38;5;241m.[39madaptive_weights(context_reprs, context_y)
[1;32m 80[0m preds [38;5;241m=[39m [38;5;28mself[39m[38;5;241m.[39mforecast(query_reprs, w, b)
File [0;32m/media/wassname/SGIronWolf/projects5/investing/DeepTime/models/DeepTIMe3.py:71[0m, in [0;36mDeepTIMe3.encode_and_decode[0;34m(self, past_x, time, offset)[0m
[1;32m 68[0m context_input [38;5;241m=[39m torch[38;5;241m.[39mcat([encoded_x, coords, time], dim[38;5;241m=[39m[38;5;241m-[39m[38;5;241m1[39m)
[1;32m 70[0m [38;5;28mprint[39m(context_input[38;5;241m.[39mshape)
[0;32m---> 71[0m context_repr [38;5;241m=[39m [38;5;28;43mself[39;49m[38;5;241;43m.[39;49m[43minr[49m[43m([49m[43mcontext_input[49m[43m)[49m
[1;32m 72[0m [38;5;28;01mreturn[39;00m context_repr
File [0;32m~/miniforge3/envs/deeptime/lib/python3.8/site-packages/torch/nn/modules/module.py:1102[0m, in [0;36mModule._call_impl[0;34m(self, *input, **kwargs)[0m
[1;32m 1098[0m [38;5;66;03m# If we don't have any hooks, we want to skip the rest of the logic in[39;00m
[1;32m 1099[0m [38;5;66;03m# this function, and just call forward.[39;00m
[1;32m 1100[0m [38;5;28;01mif[39;00m [38;5;129;01mnot[39;00m ([38;5;28mself[39m[38;5;241m.[39m_backward_hooks [38;5;129;01mor[39;00m [38;5;28mself[39m[38;5;241m.[39m_forward_hooks [38;5;129;01mor[39;00m [38;5;28mself[39m[38;5;241m.[39m_forward_pre_hooks [38;5;129;01mor[39;00m _global_backward_hooks
[1;32m 1101[0m [38;5;129;01mor[39;00m _global_forward_hooks [38;5;129;01mor[39;00m _global_forward_pre_hooks):
[0;32m-> 1102[0m [38;5;28;01mreturn[39;00m [43mforward_call[49m[43m([49m[38;5;241;43m*[39;49m[38;5;28;43minput[39;49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mkwargs[49m[43m)[49m
[1;32m 1103[0m [38;5;66;03m# Do not call functions when jit is used[39;00m
[1;32m 1104[0m full_backward_hooks, non_full_backward_hooks [38;5;241m=[39m [], []
File [0;32m/media/wassname/SGIronWolf/projects5/investing/DeepTime/models/modules/inrplus2.py:45[0m, in [0;36mINRPlus2.forward[0;34m(self, x)[0m
[1;32m 43[0m [38;5;28;01mif[39;00m [38;5;28mself[39m[38;5;241m.[39mn_fourier_feats[38;5;241m>[39m[38;5;241m0[39m:
[1;32m 44[0m f [38;5;241m=[39m torch[38;5;241m.[39mconcat([f, x], [38;5;241m-[39m[38;5;241m1[39m)
[0;32m---> 45[0m [38;5;28;01mreturn[39;00m [38;5;28;43mself[39;49m[38;5;241;43m.[39;49m[43mlayers[49m[43m([49m[43mf[49m[38;5;241;43m.[39;49m[43mpermute[49m[43m([49m[43m([49m[38;5;241;43m0[39;49m[43m,[49m[43m [49m[38;5;241;43m2[39;49m[43m,[49m[43m [49m[38;5;241;43m1[39;49m[43m)[49m[43m)[49m[43m)[49m[38;5;241m.[39mpermute(([38;5;241m0[39m, [38;5;241m2[39m, [38;5;241m1[39m))
File [0;32m~/miniforge3/envs/deeptime/lib/python3.8/site-packages/torch/nn/modules/module.py:1102[0m, in [0;36mModule._call_impl[0;34m(self, *input, **kwargs)[0m
[1;32m 1098[0m [38;5;66;03m# If we don't have any hooks, we want to skip the rest of the logic in[39;00m
[1;32m 1099[0m [38;5;66;03m# this function, and just call forward.[39;00m
[1;32m 1100[0m [38;5;28;01mif[39;00m [38;5;129;01mnot[39;00m ([38;5;28mself[39m[38;5;241m.[39m_backward_hooks [38;5;129;01mor[39;00m [38;5;28mself[39m[38;5;241m.[39m_forward_hooks [38;5;129;01mor[39;00m [38;5;28mself[39m[38;5;241m.[39m_forward_pre_hooks [38;5;129;01mor[39;00m _global_backward_hooks
[1;32m 1101[0m [38;5;129;01mor[39;00m _global_forward_hooks [38;5;129;01mor[39;00m _global_forward_pre_hooks):
[0;32m-> 1102[0m [38;5;28;01mreturn[39;00m [43mforward_call[49m[43m([49m[38;5;241;43m*[39;49m[38;5;28;43minput[39;49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mkwargs[49m[43m)[49m
[1;32m 1103[0m [38;5;66;03m# Do not call functions when jit is used[39;00m
[1;32m 1104[0m full_backward_hooks, non_full_backward_hooks [38;5;241m=[39m [], []
File [0;32m~/miniforge3/envs/deeptime/lib/python3.8/site-packages/torch/nn/modules/container.py:141[0m, in [0;36mSequential.forward[0;34m(self, input)[0m
[1;32m 139[0m [38;5;28;01mdef[39;00m [38;5;21mforward[39m([38;5;28mself[39m, [38;5;28minput[39m):
[1;32m 140[0m [38;5;28;01mfor[39;00m module [38;5;129;01min[39;00m [38;5;28mself[39m:
[0;32m--> 141[0m [38;5;28minput[39m [38;5;241m=[39m [43mmodule[49m[43m([49m[38;5;28;43minput[39;49m[43m)[49m
[1;32m 142[0m [38;5;28;01mreturn[39;00m [38;5;28minput[39m
File [0;32m~/miniforge3/envs/deeptime/lib/python3.8/site-packages/torch/nn/modules/module.py:1102[0m, in [0;36mModule._call_impl[0;34m(self, *input, **kwargs)[0m
[1;32m 1098[0m [38;5;66;03m# If we don't have any hooks, we want to skip the rest of the logic in[39;00m
[1;32m 1099[0m [38;5;66;03m# this function, and just call forward.[39;00m
[1;32m 1100[0m [38;5;28;01mif[39;00m [38;5;129;01mnot[39;00m ([38;5;28mself[39m[38;5;241m.[39m_backward_hooks [38;5;129;01mor[39;00m [38;5;28mself[39m[38;5;241m.[39m_forward_hooks [38;5;129;01mor[39;00m [38;5;28mself[39m[38;5;241m.[39m_forward_pre_hooks [38;5;129;01mor[39;00m _global_backward_hooks
[1;32m 1101[0m [38;5;129;01mor[39;00m _global_forward_hooks [38;5;129;01mor[39;00m _global_forward_pre_hooks):
[0;32m-> 1102[0m [38;5;28;01mreturn[39;00m [43mforward_call[49m[43m([49m[38;5;241;43m*[39;49m[38;5;28;43minput[39;49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mkwargs[49m[43m)[49m
[1;32m 1103[0m [38;5;66;03m# Do not call functions when jit is used[39;00m
[1;32m 1104[0m full_backward_hooks, non_full_backward_hooks [38;5;241m=[39m [], []
File [0;32m~/miniforge3/envs/deeptime/lib/python3.8/site-packages/torch/nn/modules/container.py:141[0m, in [0;36mSequential.forward[0;34m(self, input)[0m
[1;32m 139[0m [38;5;28;01mdef[39;00m [38;5;21mforward[39m([38;5;28mself[39m, [38;5;28minput[39m):
[1;32m 140[0m [38;5;28;01mfor[39;00m module [38;5;129;01min[39;00m [38;5;28mself[39m:
[0;32m--> 141[0m [38;5;28minput[39m [38;5;241m=[39m [43mmodule[49m[43m([49m[38;5;28;43minput[39;49m[43m)[49m
[1;32m 142[0m [38;5;28;01mreturn[39;00m [38;5;28minput[39m
File [0;32m~/miniforge3/envs/deeptime/lib/python3.8/site-packages/torch/nn/modules/module.py:1102[0m, in [0;36mModule._call_impl[0;34m(self, *input, **kwargs)[0m
[1;32m 1098[0m [38;5;66;03m# If we don't have any hooks, we want to skip the rest of the logic in[39;00m
[1;32m 1099[0m [38;5;66;03m# this function, and just call forward.[39;00m
[1;32m 1100[0m [38;5;28;01mif[39;00m [38;5;129;01mnot[39;00m ([38;5;28mself[39m[38;5;241m.[39m_backward_hooks [38;5;129;01mor[39;00m [38;5;28mself[39m[38;5;241m.[39m_forward_hooks [38;5;129;01mor[39;00m [38;5;28mself[39m[38;5;241m.[39m_forward_pre_hooks [38;5;129;01mor[39;00m _global_backward_hooks
[1;32m 1101[0m [38;5;129;01mor[39;00m _global_forward_hooks [38;5;129;01mor[39;00m _global_forward_pre_hooks):
[0;32m-> 1102[0m [38;5;28;01mreturn[39;00m [43mforward_call[49m[43m([49m[38;5;241;43m*[39;49m[38;5;28;43minput[39;49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mkwargs[49m[43m)[49m
[1;32m 1103[0m [38;5;66;03m# Do not call functions when jit is used[39;00m
[1;32m 1104[0m full_backward_hooks, non_full_backward_hooks [38;5;241m=[39m [], []
File [0;32m/media/wassname/SGIronWolf/projects5/investing/DeepTime/models/modules/causalinception.py:92[0m, in [0;36mInceptionBlockPlus.forward[0;34m(self, x)[0m
[1;32m 90[0m [38;5;28;01mfor[39;00m i [38;5;129;01min[39;00m [38;5;28mrange[39m([38;5;28mself[39m[38;5;241m.[39mdepth):
[1;32m 91[0m [38;5;28;01mif[39;00m [38;5;28mself[39m[38;5;241m.[39mkeep_prob[i] [38;5;241m>[39m random[38;5;241m.[39mrandom() [38;5;129;01mor[39;00m [38;5;129;01mnot[39;00m [38;5;28mself[39m[38;5;241m.[39mtraining:
[0;32m---> 92[0m x [38;5;241m=[39m [38;5;28;43mself[39;49m[38;5;241;43m.[39;49m[43minception[49m[43m[[49m[43mi[49m[43m][49m[43m([49m[43mx[49m[43m)[49m
[1;32m 93[0m [38;5;28;01mif[39;00m [38;5;28mself[39m[38;5;241m.[39mresidual [38;5;129;01mand[39;00m i [38;5;241m%[39m [38;5;241m3[39m [38;5;241m==[39m [38;5;241m2[39m:
[1;32m 94[0m res [38;5;241m=[39m x [38;5;241m=[39m [38;5;28mself[39m[38;5;241m.[39mact[i[38;5;241m/[39m[38;5;241m/[39m[38;5;241m3[39m]([38;5;28mself[39m[38;5;241m.[39madd(x, [38;5;28mself[39m[38;5;241m.[39mshortcut[i[38;5;241m/[39m[38;5;241m/[39m[38;5;241m3[39m](res)))
File [0;32m~/miniforge3/envs/deeptime/lib/python3.8/site-packages/torch/nn/modules/module.py:1102[0m, in [0;36mModule._call_impl[0;34m(self, *input, **kwargs)[0m
[1;32m 1098[0m [38;5;66;03m# If we don't have any hooks, we want to skip the rest of the logic in[39;00m
[1;32m 1099[0m [38;5;66;03m# this function, and just call forward.[39;00m
[1;32m 1100[0m [38;5;28;01mif[39;00m [38;5;129;01mnot[39;00m ([38;5;28mself[39m[38;5;241m.[39m_backward_hooks [38;5;129;01mor[39;00m [38;5;28mself[39m[38;5;241m.[39m_forward_hooks [38;5;129;01mor[39;00m [38;5;28mself[39m[38;5;241m.[39m_forward_pre_hooks [38;5;129;01mor[39;00m _global_backward_hooks
[1;32m 1101[0m [38;5;129;01mor[39;00m _global_forward_hooks [38;5;129;01mor[39;00m _global_forward_pre_hooks):
[0;32m-> 1102[0m [38;5;28;01mreturn[39;00m [43mforward_call[49m[43m([49m[38;5;241;43m*[39;49m[38;5;28;43minput[39;49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mkwargs[49m[43m)[49m
[1;32m 1103[0m [38;5;66;03m# Do not call functions when jit is used[39;00m
[1;32m 1104[0m full_backward_hooks, non_full_backward_hooks [38;5;241m=[39m [], []
File [0;32m/media/wassname/SGIronWolf/projects5/investing/DeepTime/models/modules/causalinception.py:52[0m, in [0;36mInceptionModulePlus.forward[0;34m(self, x)[0m
[1;32m 50[0m input_tensor [38;5;241m=[39m x
[1;32m 51[0m x [38;5;241m=[39m [38;5;28mself[39m[38;5;241m.[39mbottleneck(x)
[0;32m---> 52[0m x [38;5;241m=[39m [38;5;28mself[39m[38;5;241m.[39mconcat([l(x) [38;5;28;01mfor[39;00m l [38;5;129;01min[39;00m [38;5;28mself[39m[38;5;241m.[39mconvs] [38;5;241m+[39m [[38;5;28;43mself[39;49m[38;5;241;43m.[39;49m[43mmp_conv[49m[43m([49m[43minput_tensor[49m[43m)[49m])
[1;32m 53[0m x [38;5;241m=[39m [38;5;28mself[39m[38;5;241m.[39mnorm(x)
[1;32m 54[0m x [38;5;241m=[39m [38;5;28mself[39m[38;5;241m.[39mconv_dropout(x)
File [0;32m~/miniforge3/envs/deeptime/lib/python3.8/site-packages/torch/nn/modules/module.py:1102[0m, in [0;36mModule._call_impl[0;34m(self, *input, **kwargs)[0m
[1;32m 1098[0m [38;5;66;03m# If we don't have any hooks, we want to skip the rest of the logic in[39;00m
[1;32m 1099[0m [38;5;66;03m# this function, and just call forward.[39;00m
[1;32m 1100[0m [38;5;28;01mif[39;00m [38;5;129;01mnot[39;00m ([38;5;28mself[39m[38;5;241m.[39m_backward_hooks [38;5;129;01mor[39;00m [38;5;28mself[39m[38;5;241m.[39m_forward_hooks [38;5;129;01mor[39;00m [38;5;28mself[39m[38;5;241m.[39m_forward_pre_hooks [38;5;129;01mor[39;00m _global_backward_hooks
[1;32m 1101[0m [38;5;129;01mor[39;00m _global_forward_hooks [38;5;129;01mor[39;00m _global_forward_pre_hooks):
[0;32m-> 1102[0m [38;5;28;01mreturn[39;00m [43mforward_call[49m[43m([49m[38;5;241;43m*[39;49m[38;5;28;43minput[39;49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mkwargs[49m[43m)[49m
[1;32m 1103[0m [38;5;66;03m# Do not call functions when jit is used[39;00m
[1;32m 1104[0m full_backward_hooks, non_full_backward_hooks [38;5;241m=[39m [], []
File [0;32m~/miniforge3/envs/deeptime/lib/python3.8/site-packages/torch/nn/modules/container.py:141[0m, in [0;36mSequential.forward[0;34m(self, input)[0m
[1;32m 139[0m [38;5;28;01mdef[39;00m [38;5;21mforward[39m([38;5;28mself[39m, [38;5;28minput[39m):
[1;32m 140[0m [38;5;28;01mfor[39;00m module [38;5;129;01min[39;00m [38;5;28mself[39m:
[0;32m--> 141[0m [38;5;28minput[39m [38;5;241m=[39m [43mmodule[49m[43m([49m[38;5;28;43minput[39;49m[43m)[49m
[1;32m 142[0m [38;5;28;01mreturn[39;00m [38;5;28minput[39m
File [0;32m~/miniforge3/envs/deeptime/lib/python3.8/site-packages/torch/nn/modules/module.py:1102[0m, in [0;36mModule._call_impl[0;34m(self, *input, **kwargs)[0m
[1;32m 1098[0m [38;5;66;03m# If we don't have any hooks, we want to skip the rest of the logic in[39;00m
[1;32m 1099[0m [38;5;66;03m# this function, and just call forward.[39;00m
[1;32m 1100[0m [38;5;28;01mif[39;00m [38;5;129;01mnot[39;00m ([38;5;28mself[39m[38;5;241m.[39m_backward_hooks [38;5;129;01mor[39;00m [38;5;28mself[39m[38;5;241m.[39m_forward_hooks [38;5;129;01mor[39;00m [38;5;28mself[39m[38;5;241m.[39m_forward_pre_hooks [38;5;129;01mor[39;00m _global_backward_hooks
[1;32m 1101[0m [38;5;129;01mor[39;00m _global_forward_hooks [38;5;129;01mor[39;00m _global_forward_pre_hooks):
[0;32m-> 1102[0m [38;5;28;01mreturn[39;00m [43mforward_call[49m[43m([49m[38;5;241;43m*[39;49m[38;5;28;43minput[39;49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mkwargs[49m[43m)[49m
[1;32m 1103[0m [38;5;66;03m# Do not call functions when jit is used[39;00m
[1;32m 1104[0m full_backward_hooks, non_full_backward_hooks [38;5;241m=[39m [], []
File [0;32m~/miniforge3/envs/deeptime/lib/python3.8/site-packages/torch/nn/modules/container.py:141[0m, in [0;36mSequential.forward[0;34m(self, input)[0m
[1;32m 139[0m [38;5;28;01mdef[39;00m [38;5;21mforward[39m([38;5;28mself[39m, [38;5;28minput[39m):
[1;32m 140[0m [38;5;28;01mfor[39;00m module [38;5;129;01min[39;00m [38;5;28mself[39m:
[0;32m--> 141[0m [38;5;28minput[39m [38;5;241m=[39m [43mmodule[49m[43m([49m[38;5;28;43minput[39;49m[43m)[49m
[1;32m 142[0m [38;5;28;01mreturn[39;00m [38;5;28minput[39m
File [0;32m~/miniforge3/envs/deeptime/lib/python3.8/site-packages/torch/nn/modules/module.py:1102[0m, in [0;36mModule._call_impl[0;34m(self, *input, **kwargs)[0m
[1;32m 1098[0m [38;5;66;03m# If we don't have any hooks, we want to skip the rest of the logic in[39;00m
[1;32m 1099[0m [38;5;66;03m# this function, and just call forward.[39;00m
[1;32m 1100[0m [38;5;28;01mif[39;00m [38;5;129;01mnot[39;00m ([38;5;28mself[39m[38;5;241m.[39m_backward_hooks [38;5;129;01mor[39;00m [38;5;28mself[39m[38;5;241m.[39m_forward_hooks [38;5;129;01mor[39;00m [38;5;28mself[39m[38;5;241m.[39m_forward_pre_hooks [38;5;129;01mor[39;00m _global_backward_hooks
[1;32m 1101[0m [38;5;129;01mor[39;00m _global_forward_hooks [38;5;129;01mor[39;00m _global_forward_pre_hooks):
[0;32m-> 1102[0m [38;5;28;01mreturn[39;00m [43mforward_call[49m[43m([49m[38;5;241;43m*[39;49m[38;5;28;43minput[39;49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mkwargs[49m[43m)[49m
[1;32m 1103[0m [38;5;66;03m# Do not call functions when jit is used[39;00m
[1;32m 1104[0m full_backward_hooks, non_full_backward_hooks [38;5;241m=[39m [], []
File [0;32m~/miniforge3/envs/deeptime/lib/python3.8/site-packages/tsai/models/layers.py:148[0m, in [0;36mCausalConv1d.forward[0;34m(self, input)[0m
[1;32m 147[0m [38;5;28;01mdef[39;00m [38;5;21mforward[39m([38;5;28mself[39m, [38;5;28minput[39m):
[0;32m--> 148[0m [38;5;28;01mreturn[39;00m [38;5;28;43msuper[39;49m[43m([49m[43mCausalConv1d[49m[43m,[49m[43m [49m[38;5;28;43mself[39;49m[43m)[49m[38;5;241;43m.[39;49m[43mforward[49m[43m([49m[43mF[49m[38;5;241;43m.[39;49m[43mpad[49m[43m([49m[38;5;28;43minput[39;49m[43m,[49m[43m [49m[43m([49m[38;5;28;43mself[39;49m[38;5;241;43m.[39;49m[43m__padding[49m[43m,[49m[43m [49m[38;5;241;43m0[39;49m[43m)[49m[43m)[49m[43m)[49m
File [0;32m~/miniforge3/envs/deeptime/lib/python3.8/site-packages/torch/nn/modules/conv.py:301[0m, in [0;36mConv1d.forward[0;34m(self, input)[0m
[1;32m 300[0m [38;5;28;01mdef[39;00m [38;5;21mforward[39m([38;5;28mself[39m, [38;5;28minput[39m: Tensor) [38;5;241m-[39m[38;5;241m>[39m Tensor:
[0;32m--> 301[0m [38;5;28;01mreturn[39;00m [38;5;28;43mself[39;49m[38;5;241;43m.[39;49m[43m_conv_forward[49m[43m([49m[38;5;28;43minput[39;49m[43m,[49m[43m [49m[38;5;28;43mself[39;49m[38;5;241;43m.[39;49m[43mweight[49m[43m,[49m[43m [49m[38;5;28;43mself[39;49m[38;5;241;43m.[39;49m[43mbias[49m[43m)[49m
File [0;32m~/miniforge3/envs/deeptime/lib/python3.8/site-packages/torch/nn/modules/conv.py:297[0m, in [0;36mConv1d._conv_forward[0;34m(self, input, weight, bias)[0m
[1;32m 293[0m [38;5;28;01mif[39;00m [38;5;28mself[39m[38;5;241m.[39mpadding_mode [38;5;241m!=[39m [38;5;124m'[39m[38;5;124mzeros[39m[38;5;124m'[39m:
[1;32m 294[0m [38;5;28;01mreturn[39;00m F[38;5;241m.[39mconv1d(F[38;5;241m.[39mpad([38;5;28minput[39m, [38;5;28mself[39m[38;5;241m.[39m_reversed_padding_repeated_twice, mode[38;5;241m=[39m[38;5;28mself[39m[38;5;241m.[39mpadding_mode),
[1;32m 295[0m weight, bias, [38;5;28mself[39m[38;5;241m.[39mstride,
[1;32m 296[0m _single([38;5;241m0[39m), [38;5;28mself[39m[38;5;241m.[39mdilation, [38;5;28mself[39m[38;5;241m.[39mgroups)
[0;32m--> 297[0m [38;5;28;01mreturn[39;00m [43mF[49m[38;5;241;43m.[39;49m[43mconv1d[49m[43m([49m[38;5;28;43minput[39;49m[43m,[49m[43m [49m[43mweight[49m[43m,[49m[43m [49m[43mbias[49m[43m,[49m[43m [49m[38;5;28;43mself[39;49m[38;5;241;43m.[39;49m[43mstride[49m[43m,[49m
[1;32m 298[0m [43m [49m[38;5;28;43mself[39;49m[38;5;241;43m.[39;49m[43mpadding[49m[43m,[49m[43m [49m[38;5;28;43mself[39;49m[38;5;241;43m.[39;49m[43mdilation[49m[43m,[49m[43m [49m[38;5;28;43mself[39;49m[38;5;241;43m.[39;49m[43mgroups[49m[43m)[49m
File [0;32m~/miniforge3/envs/deeptime/lib/python3.8/site-packages/fastai/torch_core.py:378[0m, in [0;36mTensorBase.__torch_function__[0;34m(cls, func, types, args, kwargs)[0m
[1;32m 376[0m [38;5;28;01mif[39;00m [38;5;28mcls[39m[38;5;241m.[39mdebug [38;5;129;01mand[39;00m func[38;5;241m.[39m[38;5;18m__name__[39m [38;5;129;01mnot[39;00m [38;5;129;01min[39;00m ([38;5;124m'[39m[38;5;124m__str__[39m[38;5;124m'[39m,[38;5;124m'[39m[38;5;124m__repr__[39m[38;5;124m'[39m): [38;5;28mprint[39m(func, types, args, kwargs)
[1;32m 377[0m [38;5;28;01mif[39;00m _torch_handled(args, [38;5;28mcls[39m[38;5;241m.[39m_opt, func): types [38;5;241m=[39m (torch[38;5;241m.[39mTensor,)
[0;32m--> 378[0m res [38;5;241m=[39m [38;5;28;43msuper[39;49m[43m([49m[43m)[49m[38;5;241;43m.[39;49m[43m__torch_function__[49m[43m([49m[43mfunc[49m[43m,[49m[43m [49m[43mtypes[49m[43m,[49m[43m [49m[43margs[49m[43m,[49m[43m [49m[43mifnone[49m[43m([49m[43mkwargs[49m[43m,[49m[43m [49m[43m{[49m[43m}[49m[43m)[49m[43m)[49m
[1;32m 379[0m dict_objs [38;5;241m=[39m _find_args(args) [38;5;28;01mif[39;00m args [38;5;28;01melse[39;00m _find_args([38;5;28mlist[39m(kwargs[38;5;241m.[39mvalues()))
[1;32m 380[0m [38;5;28;01mif[39;00m [38;5;28missubclass[39m([38;5;28mtype[39m(res),TensorBase) [38;5;129;01mand[39;00m dict_objs: res[38;5;241m.[39mset_meta(dict_objs[[38;5;241m0[39m],as_copy[38;5;241m=[39m[38;5;28;01mTrue[39;00m)
File [0;32m~/miniforge3/envs/deeptime/lib/python3.8/site-packages/torch/_tensor.py:1051[0m, in [0;36mTensor.__torch_function__[0;34m(cls, func, types, args, kwargs)[0m
[1;32m 1048[0m [38;5;28;01mreturn[39;00m [38;5;28mNotImplemented[39m
[1;32m 1050[0m [38;5;28;01mwith[39;00m _C[38;5;241m.[39mDisableTorchFunction():
[0;32m-> 1051[0m ret [38;5;241m=[39m [43mfunc[49m[43m([49m[38;5;241;43m*[39;49m[43margs[49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mkwargs[49m[43m)[49m
[1;32m 1052[0m [38;5;28;01mif[39;00m func [38;5;129;01min[39;00m get_default_nowrap_functions():
[1;32m 1053[0m [38;5;28;01mreturn[39;00m ret
[0;31mRuntimeError[0m: CUDA out of memory. Tried to allocate 24.00 MiB (GPU 0; 10.74 GiB total capacity; 8.00 GiB already allocated; 50.12 MiB free; 8.16 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF
In call to configurable 'train' (<function train at 0x7f4045284ee0>)
In call to configurable 'instance' (<function ForecastExperiment.instance at 0x7f4045284550>)
In call to configurable 'run' (<function Experiment.run at 0x7f4092a49550>)In [ ]:
%debugIn [ ]: