next_action = next_action + noiseclamp-selfmax_action selfmax_actionRuntimeError The size of tensor a 2 must match the size of tensor b 0 at non-singleton dimension 0
This error occurs when the size of the tensor 'noise' does not match the size of the tensor 'next_action' in any non-singleton dimension. This means that the two tensors cannot be added or subtracted together.
To fix this error, you need to ensure that the size of the 'noise' tensor matches the size of the 'next_action' tensor in all dimensions. You can check the size of each tensor using the '.size()' method.
If the sizes do not match, you can either resize one of the tensors or generate a new 'noise' tensor with the correct size.
For example, if 'next_action' has a size of (2, 3) and 'noise' has a size of (2), you can resize 'noise' to (2, 1) using the '.unsqueeze()' method before adding it to 'next_action':
next_action = (next_action + noise.unsqueeze(1)).clamp(-self.max_action, self.max_action)
``
原文地址: http://www.cveoy.top/t/topic/hpIx 著作权归作者所有。请勿转载和采集!