ziyu-zui / heart-arrhythmia-diagnosis-with-deep-learning

codes for paper: ECG-Based Heart Arrhythmia Diagnosis Through Attentional Convolutional Neural Networks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Could you please inform me of the purpose of the "self.weight" in your code?

everglowgh opened this issue · comments

I noticed that there is a variable 'self.weight' in Class CNN that appears to be unused from my perspective, cuz it is unused in forward function. I know it might actually play a crucial role. Could you please explain the purpose or significance of that variable?
... ...
self.fc = nn.Linear(1984, 200)
self.out = nn.Linear(200, 5)
self.weight = Parameter(torch.Tensor(2, 32))

def forward(self, x):
    x = self.conv1(x)
    x = self.conv2(x)
    x = x.view(x.size(0), -1)

    x = F.relu(self.fc(x))
    x = F.dropout(x, 0.2)

    output = self.out(x)
    return output, x
    ... ...
commented

Hi @everglowgh, thanks so much for pointing it out. I'm sorry that I missed such an important thing in code cleaning.

The self.weight is the tensor vector for attention weights, which will learn the importance of each timestamp. It should be element-wise multiplied with the input data. I messed up the code versions, and have corrected it now.

Thanks again.

Hi @everglowgh, thanks so much for pointing it out. I'm sorry that I missed such an important thing in code cleaning.

The self.weight is the tensor vector for attention weights, which will learn the importance of each timestamp. It should be element-wise multiplied with the input data. I messed up the code versions, and have corrected it now.

Thanks again.

Ok, I see. Thanks so much for your reply!