stefanonardo / pytorch-esn

An Echo State Network module for PyTorch.
MIT License
211 stars 43 forks source link

Fixed 'single memory location' error. #9

Closed Jmmaroli closed 4 years ago

Jmmaroli commented 4 years ago

An error occurs when line 47 is reached in the "washout_tensor" function of "utilities.py". See traceback and runtime error below. A fix is applied by cloning the "tmp" tensor as suggested by the error message.

Traceback (most recent call last):

File "C:\Users\jmmar\classify.py", line 133, in model(trX, washout, None, trY[washout[0]:trainSize,0,:])

File "C:\ProgramData\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 722, in _call_impl result = self.forward(*input, **kwargs)

File "C:\Users\jmmar\torchesn\nn\echo_state_network.py", line 148, in forward output, seq_lengths = washout_tensor(output, washout, seq_lengths)

File "C:\Users\jmmar\torchesn\utils\utilities.py", line 48, in washout_tensor tensor[:seq_lengths[b] - washout[b], b] = tmp

RuntimeError: unsupported operation: some elements of the input tensor and the written-to tensor refer to a single memory location. Please clone() the tensor before performing the operation.

stefanonardo commented 4 years ago

Hi, thank you for the PR ;) I already fixed it on my local installation but I will merge your PR