ivannz / cplxmodule

Complex-valued neural networks for pytorch and Variational Dropout for real and complex layers.
MIT License
134 stars 27 forks source link

cplx_trabelsi_independent_ not working for CplxLinear layer #11

Closed Ujjawal-K-Panchal closed 4 years ago

Ujjawal-K-Panchal commented 4 years ago

I was trying to use cplxmodule.nn.init.cplx_trabelsi_independent_ for the cplxmodule.nn.CplxLinear layer as given in the minimalistic snipped below.

from cplxmodule.nn import CplxLinear
from cplxmodule.nn.init import cplx_trabelsi_independent_ 

fc1 = CplxLinear(1250,500)
cplx_trabelsi_independent_(fc1.weight)

However, it gives me the below provided error. Am I using it incorrectly? Help is appreciated. File "<path>/python3.7/site-packages/cplxmodule/nn/init.py", line 114, in cplx_trabelsi_independent_ M = M.reshape(cplx.shape) ValueError: cannot reshape array of size 250000 into shape (500,1250)

ivannz commented 4 years ago

Thank you for drawing my attention to this, @Ujjawal-K-Panchal ! due to somewhat late stage addition of that particular init haven't tested it thoroughly. Judging by the issues that accumulate around it i should have been more attentive. i will take care of this issue tomorrow evening.

ivannz commented 4 years ago

@Ujjawal-K-Panchal So it turns out I used full_matrices=False in the SVD, which is being used to produce a semi-unitary init matrix. This led to the an incompatible matrix shape in the case when the linear layer maps n-dim features to m-dim features with n > m. This has gone unnoticed, because I did not implement a proper test suite.

It is fixed now.

Ujjawal-K-Panchal commented 4 years ago

Thank you for the quick response!