KoopmanLab icon indicating copy to clipboard operation
KoopmanLab copied to clipboard

Demo code running issue

Open linanzhang opened this issue 1 year ago • 1 comments

Hello,

I played around with the parameters in the demo code and got a RuntimeError. When uploading the dataset and building the network, I changed t_in and t_out:

train_loader, test_loader = kp.data.navier_stokes(data_path, batch_size = 10, T_in = t_in, T_out = t_out, type = "1e-3", sub = 1)

koopman_model = kp.model.koopman(backbone = "KNO2d", autoencoder = "MLP", o = o, m = m, r = r, t_in = t_in, device = device)

An error message promts when calling koopman_model.train(), saying

RuntimeError: The size of tensor a (163840) must match the size of tensor b (122880) at non-singleton dimension 1

The error message is the same regarless of the value of t_in and t_out. What are the requirements on t_in and t_out?

Thank you.

linanzhang avatar Sep 27 '24 02:09 linanzhang

I have encountered the same problem as you when modifying T_in and T_out. I'm not sure if our codes are the same, but I'll just describe the problem I encountered and how I solved it.

The author uses T_in and T_out as input parameters multiple times in the functions for training, testing, and generating data. However, they are set as default input parameters. This means that if you don't specify the values of T_in and T_out when calling the functions, the functions will automatically use the default values. This may lead to a mismatch in the dimensions of the training and data generation.

I checked the code of these functions and then assigned values to T_in and T_out when calling the functions for training, testing, and generating data. This solved the problem.

Williamlliw avatar Jun 24 '25 03:06 Williamlliw