akankshakshurai/cuda-error-resolution-analysis huggingface dataset:
Support of probability distribution

username: nmourdou
cooked: <p>Hey guys,</p>
<p>I have a distribution of a <strong>continuous random variable (Relaxed Bernoulli)</strong> that has been created by an affine transformation, namely</p>
<p><strong>m = TransformedDistribution(beta, AffineTransform(a, b))</strong></p>
<p>I want to access its support, in order to check if certain observations are in it.  When I type</p>
<p><strong>m.support</strong></p>
<p>I just get : <strong>IndependentConstraint(Real(), 1).</strong></p>
<p>Is there a way to get it or at least check if an example belongs to it?</p>
<p>Thank you</p>

username: rad
cooked: <p>I think you can check if an example belongs to it:</p>
<pre><code class="lang-auto">m.support.check(value)
</code></pre>

username: nmourdou
cooked: <p>Thank you Andrei. One more question: Although I get for some inputs using this, that they do belong in the support, when I try to compute their log-likelihood I still get the error:</p>
<p><strong>ValueError: The value argument must be within the support</strong><br>
Any ideas on why this may be happening?</p>
Interleaving a set of channels during concatenation

username: shreyas_kamath
cooked: <p>Hi,</p>
<p>I am trying to perform a quaternion space concatenation which requires the four dimensions [r,i,j,k] to be concatenated. According to quaternion theory, we cannot apply the torch.cat function directly as they would mess up the components. So I managed to perform this action using the quaternion_concat function which is adapted from <a href="https://github.com/vanzytay/QuaternionTransformers/blob/master/layers/qlib.py" rel="noopener nofollow ugc">here</a>.</p>
<p>For example, <code>tensor_1</code> and <code>tensor_2</code> are two tensors that needs to be concatenated and it has 16 channels each. That means it has 4 channels of <code>r,i,j,k</code> respectively in a stacked fashion. I use the torch.chunk function to separate these and concatenate them separately. Is there any way I could perform this in a better way?</p>
<pre><code class="lang-auto">import torch

def quarternion_concat(x, dim=2):
    output = [[] for i in range(4)]
    for _x in x:
        sp = torch.chunk(_x, 4, dim=dim)
        for i in range(4):
            output[i].append(sp[i])

    final = []
    for o in output:
        o = torch.cat(o, dim)
        final.append(o)

    return torch.cat(final, dim)


tensor_1 = torch.randn((1, 16, 64, 64), requires_grad=False)
tensor_2 = torch.randn((1, 16, 64, 64), requires_grad=False)

tensor3 = quarternion_concat([tensor_1, tensor_2], dim=1)
</code></pre>
<p>Any help is appreciated.<br>
Thank you,<br>
Shreyas Kamath</p>
Handling singular matrices when backprop

username: Nbout
cooked: <p>Hey guys!</p>
<p>I am currently running into the following problem:<br>
I’ll get the<br>
<code>RuntimeError: inverse_cuda: For batch 0: U(1,1) is zero, singular U.</code><br>
message, when computing lots of determinants during the forward pass. Do you know how to tackle this problem appropriately? I am aware of the fact that the matrices have to be non-singular in order to compute its gradients - but how to make sure that only non-singular matrices are considered when backwarding?</p>
<p>Thanks a lot in advance!</p>

username: danielf
cooked: <p>I discovered that there are singular matrices when doing SVD decomposition - as part of doing PCA. I’m using <code>torch.pca_lowrank(matrix,...)</code> to do dimensional reduction. You can check whether the middle vector has zeros in it (singular values), e.g.</p>
<pre><code class="lang-auto">reduced, eigenvalues, _ = torch.pca_lowrank(matrix, q=4)
if not eigenvalues.prod().is_nonzero():
    raise Exception
</code></pre>
<p>Hope it helps.</p>