AI4HealthUOL / SSSD-ECG

Repository for the paper: 'Diffusion-based Conditional ECG Generation with Structured State Space Models'
MIT License
42 stars 6 forks source link

Get 'ptbxl_train_labels.npy' file #5

Closed XLIU430 closed 1 year ago

XLIU430 commented 1 year ago

Hello, I tried to get the 'ptbxl_train_labels.npy' file by running ecg_data_preprocessing.ipynb. In the end of the notebook, I got the dataloaders like 'ds_test', and dataframes like 'df_test'. How should I get 'ptbxl_train_labels.npy' file from those data?

juanlopezcode commented 1 year ago

Hello @XLIU430, you can easily iterate though these dataloaders and obtain the labes. You can either use a for loop and append the second element for each batch (x,y), or also obtain them directly by calling dataloader.dataset.labels. Hope this helps

XLIU430 commented 1 year ago

Hello @XLIU430, you can easily iterate though these dataloaders and obtain the labes. You can either use a for loop and append the second element for each batch (x,y), or also obtain them directly by calling dataloader.dataset.labels. Hope this helps

Thank you sir, I managed to get the label data and train data. However when I train a new model using train.py or generating ECG by using inference.py. There is a runtime error showing below. What do you think what might cause it? Sorry I am new to tensorflow

Exception has occurred: RuntimeError mat1 and mat2 shapes cannot be multiplied (6x44 and 71x128) File "C:\Users\OEM\Desktop\SSSD-ECG-main\src\sssd\models\SSSD_ECG.py", line 201, in forward label_embed = label @ self.embedding.weight if self.embedding is not None else None File "C:\Users\OEM\Desktop\SSSD-ECG-main\src\sssd\utils\util.py", line 185, in training_loss_label epsilon_theta = net((transformed_X, label, diffusion_steps.view(B,1),)) File "C:\Users\OEM\Desktop\SSSD-ECG-main\src\sssd\train.py", line 109, in train loss = training_loss_label(net, nn.MSELoss(), X, diffusion_hyperparams) File "C:\Users\OEM\Desktop\SSSD-ECG-main\src\sssd\train.py", line 156, in train(**train_config) RuntimeError: mat1 and mat2 shapes cannot be multiplied (6x44 and 71x128) Screenshot 2023-05-18 204412

juanlopezcode commented 1 year ago

It seems you changed either the label set or the configuration file. In the JSON configuration file you should pass as embedding dimension the size of your label set. Here labels are 44 and embeddings 71 probably

dtt355 commented 1 year ago

I ran SSSD-ECG-main/src/ptb_xl/ecg_data_preprocessing.ipynb to get the training data and the training label, but I encountered the same problem as XLIU430. I did not change the configuration file, and the label I got was also 44 instead of 71. What parameters need to be changed during loss data preprocessing?