GeometricBCI / Tensor-CSPNet-and-Graph-CSPNet

This is the python implementation of Tensor-CSPNet and Graph-CSPNet.
Other
56 stars 8 forks source link

Could you provide the training code for the tensor-CSPnet ? #1

Open awei-97 opened 3 months ago

awei-97 commented 3 months ago

Hello, I noticed that you provided the complete code for Graph-CSPnet and part of the code for tensor-CSPnet (data loading and model files). I tried to train using this part of the tensor-CSPnet code, but the results were not good. Could you provide the complete code for tensor-CSPnet?

GeometricBCI commented 3 months ago

I'm glad you're interested in my work. Could you please specify which dataset and under what scenarios you found the results "were not good"? Also, how did you preprocess your raw EEGs, as that might be a significant factor affecting the results?

awei-97 commented 3 months ago

Thank you very much for your reply. I first tried the graph-CSPnet, using the BCIC dataset. The data loading, preprocessing, and the default parameter settings of the model, were all done according to the code you provided, and the final result was very good.

Next, I tried tensor-CSPnet. I saw that you provided the load data and model files. Without making any other changes, I simply called these two apis , keeping the rest consistent with graph-CSPnet.

 # NCHW Format: (batch_size, window_num*band_num, 4, 4) ---> (batch_size, 1, window_num, band_num * 4 * 4)
        x_vec = x_log.view(x_log.shape[0], 1, window_num, -1)

        y     = self.Classifier(self.Temporal_Block(x_vec).reshape(x.shape[0], -1))

It's mainly in the final convolutional layer, where there's an issue with the convolutional kernel size being too large: the size of the convolutional kernel defined by self.Temporal_Block(x_vec) is (self.kernel_size, self.tcn_width*self.dims[-1]**2), which calculates to [2 x 4356], but the shape of x_vec is only [128, 1, 2, 484]. I reduced the kernel size here to allow the program to continue running, but the effect was not good, with a mean accuracy of only 60%.

Could you provide the complete tensor-CSPnet code? I would like to study it and correct the error. Thank you very much.

GeometricBCI commented 3 months ago

Thank you for your classification. My code should be fine since my collaborators have been able to reproduce those results using Tensor-CSPNet. At a glance, it seems the issue might lie in the direction of the tensor after flattening, resulting in an overly large dimension.

I've uploaded the training code for Tensor-CSPNet. The reason I hadn't uploaded it earlier is that this part of the code doesn't differ significantly from the training code for Graph-CSPNet.

GeometricBCI commented 3 months ago

clarification*