Closed ooghry closed 1 year ago
Running on CPU:
RuntimeError('index -1 is out of bounds for dimension 1 with size 10260')
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/optuna/study/_optimize.py", line 196, in _run_trial
value_or_values = func(trial)
File "<ipython-input-12-e61dd5c8773c>", line 64, in __call__
callbacks=[my_callback],
File "/usr/local/lib/python3.7/dist-packages/pytorch_tabnet/abstract_model.py", line 223, in fit
self._train_epoch(train_dataloader)
File "/usr/local/lib/python3.7/dist-packages/pytorch_tabnet/abstract_model.py", line 434, in _train_epoch
batch_logs = self._train_batch(X, y)
File "/usr/local/lib/python3.7/dist-packages/pytorch_tabnet/abstract_model.py", line 469, in _train_batch
output, M_loss = self.network(X)
File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1130, in _call_impl
return forward_call(*input, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/pytorch_tabnet/tab_network.py", line 583, in forward
return self.tabnet(x)
File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1130, in _call_impl
return forward_call(*input, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/pytorch_tabnet/tab_network.py", line 468, in forward
steps_output, M_loss = self.encoder(x)
File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1130, in _call_impl
return forward_call(*input, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/pytorch_tabnet/tab_network.py", line 160, in forward
M = self.att_transformers[step](prior, att)
File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1130, in _call_impl
return forward_call(*input, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/pytorch_tabnet/tab_network.py", line 637, in forward
x = self.selector(x)
File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1130, in _call_impl
return forward_call(*input, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/pytorch_tabnet/sparsemax.py", line 204, in forward
return entmax15(input, self.dim)
File "/usr/local/lib/python3.7/dist-packages/pytorch_tabnet/sparsemax.py", line 127, in forward
tau_star, _ = Entmax15Function._threshold_and_support(input, dim)
File "/usr/local/lib/python3.7/dist-packages/pytorch_tabnet/sparsemax.py", line 159, in _threshold_and_support
tau_star = tau.gather(dim, support_size - 1)
RuntimeError: index -1 is out of bounds for dimension 1 with size 10260
@ooghry I think this error happens in a few cases that you should investigate:
It's probably one or the other, let me know if it's not.
@Optimox Thank you for your reply.
I don't have any NaN or any categorical feature in my data.
I add cat_idxs=[],cat_dims=[],cat_emb_dim=1
as argument, it seems my first problem gone.
But my notebook crashes after some trials on Google Colab(25Gb ram) because of memory overflow. It would be nice if we had control over how much memory TabNet can use.
So you were probably using embeddings but something was wrong in the indexing. Memory overflow might happen and I'll be happy to discuss how we can reduce tabnet consumption. But I think as long as there is no memory leak it's alright. Just reduce your batch size if needed, or the size of your model if you don't have enough computing power.
I'm trying to use Optuna with TabNet on Google Colab. At some point, I got this error. (I do not know if it's a natural trace or if other things hide behind the Cuda.)
The only weird thing I do is
weight={0:2.,1:2.,2:.001}
argument:Any comment would be appreciated.