Closed AlexKnowsIt closed 9 months ago
Thank you for the question:))
Could you please share a reproducible code example that gives you this error?
Yes of course :)
https://gist.github.com/AlexKnowsIt/47fb35f8d9ad10ccf957bd583ce846c3
Perfect! Thank you for sharing.
It seems like some of your assets have constant returns. More specifically, if you put a breakpoint
inside of the forward
of your NCO_Netz
and inspect rets[0, :, 0]
you will get
tensor([-0.1323, -0.1323, -0.1323, -0.1323, -0.1323, -0.1323, -0.1323, -0.1323,
-0.1323, -0.1323, -0.1323, -0.1323, -0.1323, -0.1323, -0.1323, -0.1323,
-0.1323, -0.1323, -0.1323, -0.1323], grad_fn=<SelectBackward>)
The covmat[0, 0]
will then look like this
tensor([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0.], grad_fn=<SelectBackward>)
Similarly, The covmat[0, 28]
will then look like this
tensor([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0.], grad_fn=<SelectBackward>)
This becomes a problem here
https://github.com/jankrepl/deepdow/blob/eb6c85845c45f89e0743b8e8c29ddb69cb78da4f/deepdow/layers/allocate.py#L138
since there will be a bunch of 0/0
and the corrmat
will contain nan
s.
Anyway, I only checked it really briefly, so I hope that it is really the root cause. However, I might be mistaken. Anyway, the error message is not really helpful in this case I have to admit:)
Hope that helps!
Closing due to inactivity
I am trying to alter the BachelierNet and change its allocation-layer to the
NCO
-layer. I read on issue #110, that you can use theNCO
algorithm inside theResample
-layer. It seems to me, that its also possible to run it without the resample, as there is acvxpy
-layer for the allocation already implemented. However, if I try to run my custom networkWhile trying to train I receive the error message
Probably I was just missusing a parameter but I can't figure out which one. What is the
torch.where()
expecting? The only thing that I changed from the BachelierNet is theallocation-layer
and the squaring of thecovmat
.