jankrepl / deepdow

Portfolio optimization with deep learning.
https://deepdow.readthedocs.io
Apache License 2.0
875 stars 136 forks source link

wrong discription in CovarianceMatrix layer? #97

Closed turmeric-blend closed 3 years ago

turmeric-blend commented 3 years ago

https://github.com/jankrepl/deepdow/blob/cab9cac9d9212dd839951f65a9c0b49ca961eec7/deepdow/layers/misc.py#L69

I think this line for the CovarianceMatrix layer should be (n_samples, lookback, n_assets)? Instead of n_channels.

jankrepl commented 3 years ago

I would say it depends. More than anything, the middle dimensions is the one that we compute the sample covariance matrix over. So maybe more neutral name like dim would be more fitting.

The reason why it depends is that we do not really know what kind of layers came before the CovarianceMatrix layer. The only thing that is fixed in deepdow is that the input tensor X has a shape (n_samples, n_channels, lookback, n_assets). What happens after is up to the user to decide.

See below two valid architectures and note that for each of them the middle dimension has a different meaning. 1. (n_samples, n_channels, lookback, n_assets) -- average over the channel dimension -- > (n_samples, lookback, n_assets) -- CovarianceMatrix --> (n_samples, n_assets, n_assets) ... 2. (n_samples, n_channels, lookback, n_assets) -- average over the lookback dimension -- > (n_samples, n_channels, n_assets) -- CovarianceMatrix --> (n_samples, n_assets, n_assets) ...

turmeric-blend commented 3 years ago

ah ok thanks.

turmeric-blend commented 3 years ago

reopen just to act as a reminder to fix this perhaps