jfpower / anfis-pytorch

Implementation of ANFIS using the pyTorch framework
MIT License
121 stars 44 forks source link

torch.gels Lapack Error in gels : Illegal Argument 5 #1

Open mentalssh opened 5 years ago

mentalssh commented 5 years ago

thanks for sharing your code, sir. I tried your code with some other time series data, I found torch.gels function is not stable. when passing through first layer of anfis, it returns nans, or after several iterations, anfis.coeff went too large, loss become inf. maybe gaussmembership functions mu and sigma which i used are not suitable for these data. Im wondering whats the suitable range of mu and sigma for setting membership functions, do you have any good suggetions? thank you in advance.

here is some error

217 y_actual_2d = y_actual.view(y_actual.shape[0], -1) 218 # Use gels to do LSE, then pick out the solution rows: --> 219 coeff2d, = torch.gels(y_actual_2d, weighted_x_2d) 220 coeff_2d = coeff_2d[0:weighted_x_2d.shape[1]] 221 # Reshape to 3D tensor: divide by rules, n_in+1, then swap last 2 dims

RuntimeError: Lapack Error in gels : Illegal Argument 5 at c:\a\w\1\s\windows\pytorch\aten\src\th\generic/THTensorLapack.cpp:252

corticalstack commented 4 years ago

Thanks very much for sharing this ANFIS solution. Iris example works great, however the sk_examples.py fails with following error:

Traceback (most recent call last): File "/home/jp/Documents/Developments/anfis-python/sk_examples.py", line 181, in classify_example() File "/home/jp/Documents/Developments/anfis-python/sk_examples.py", line 123, in classify_example train_fuzzy(model, X, y) File "/home/jp/Documents/Developments/anfis-python/sk_examples.py", line 111, in train_fuzzy net.fit(X, y) File "/usr/local/lib/python3.7/dist-packages/skorch/net.py", line 852, in fit self.partial_fit(X, y, fit_params) File "/usr/local/lib/python3.7/dist-packages/skorch/net.py", line 811, in partial_fit self.fit_loop(X, y, fit_params) File "/usr/local/lib/python3.7/dist-packages/skorch/net.py", line 766, in fit_loop self.notify('on_epoch_end', on_epoch_kwargs) File "/usr/local/lib/python3.7/dist-packages/skorch/net.py", line 288, in notify getattr(cb, method_name)(self, cb_kwargs) File "/home/jp/Documents/Developments/anfis-python/sk_examples.py", line 42, in on_epoch_end net.module.fit_coeff(dataset_train.X, dataset_train.y) File "/home/jp/Documents/Developments/anfis-python/anfis.py", line 342, in fit_coeff self.layer['consequent'].fit_coeff(x, self.weights, y_actual) File "/home/jp/Documents/Developments/anfis-python/anfis.py", line 226, in fit_coeff coeff2d, = torch.gels(y_actual_2d, weighted_x_2d) AttributeError: module 'torch' has no attribute 'gels

At line 226 in anfis.py coeff2d, = torch.gels(y_actual_2d, weighted_x_2d)

Any plans or recommendation to fix? Many thanks

scissorsf commented 4 years ago

For version > 1.2 WARNING torch.gels() is deprecated in favour of torch.lstsq() and will be removed in the next release. Please use torch.lstsq() instead.

s-kostyuk commented 2 years ago

Related: #3 Fixed by: #4