mhh0318 / EE7207

Assignment
1 stars 0 forks source link

Logical Confusion and BUG #1

Open BENZEMA216 opened 2 years ago

BENZEMA216 commented 2 years ago

Hi mhh0318,

I am also studying the course EE7207. Thank you for your repo, and it does help me a lot.

I got some logical problems with your codes.

def train(self, X, Y):
        """ X: matrix of dimensions n x indim
            y: column vector of dimension n x 1 """

        # calculate activations of RBFs
        s = (X.size(0),16,33)
        d_max = self.maxDis(self.centers)
        sigma = d_max / np.sqrt(2 * self.centers.size(0))
        x = X.unsqueeze(1).expand(s)
        c = self.centers.unsqueeze(0).expand(s)
        distance_2 = (x - c).pow(2).sum(-1)
        bs = torch.ones_like(Y).cuda()
        G = torch.exp(-distance_2 / (2 * sigma ** 2))
        G = torch.cat((G,bs),1) 

        # calculate output weights (pseudoinverse)
        self.W = torch.matmul(torch.matmul(torch.inverse(torch.matmul(G.T, G)), G.T),Y.double())
        return self.W

In this part, I am confused why we need 'bs' here, 'bs' seems useless…………and if we cat 'bs' with 'G', it is obvious that the calculation of self.W will fail……

Looking forward to hear you.

mhh0318 commented 2 years ago

Hi, it's biases, you can discard it.

BENZEMA216 commented 2 years ago

Thanks dude

2021年9月26日 上午9:41,Ming @.***> 写道:

Hi, it's biases, you can discard it.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mhh0318/EE7207/issues/1#issuecomment-927211401, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKO7X4JHYP2AO4DI2FBEFPDUDZ24BANCNFSM5EXYI6DQ. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.