Photon-AI-Research / NeuralSolvers

Neural network based solvers for partial differential equations and inverse problems :milky_way:. Implementation of physics-informed neural networks in pytorch.
MIT License
141 stars 46 forks source link

UserWarning in InitalCondition.py #20

Closed maxxxzdn closed 3 years ago

maxxxzdn commented 3 years ago

https://github.com/ComputationalRadiationPhysics/NeuralSolvers/blob/2a9457257b35265d219db245eb765c6132559748/PINNFramework/InitalCondition.py#L28

/home/maxxxzdn/.local/lib/python3.8/site-packages/torch/nn/modules/loss.py:446: UserWarning: Using a target size (torch.Size([batch_size])) that is different to the input size (torch.Size([batch_size, 1])). This will likely lead to incorrect results due to broadcasting. Please ensure they have the same size. return F.mse_loss(input, target, reduction=self.reduction)

Using prediction = model(x).reshape(-1) solves the problem

StillerPatrick commented 3 years ago

could you say me which was the shape of x in the initial condition ?

maxxxzdn commented 3 years ago

It was [batch_size,3]

StillerPatrick commented 3 years ago

but looks correct to me ?

StillerPatrick commented 3 years ago

and the shape of the predictions ?

maxxxzdn commented 3 years ago

[batch_size, 1]

Perhaps it worked fine, but I got this annoying UserWarning that [batch_size] != [batch_size,1]

StillerPatrick commented 3 years ago

ok :) if you shape your data correctly which is always batch size one, it works fine :)

maxxxzdn commented 3 years ago

I see. I will reshape my output tensor in the dataset then. Probably it makes sense to write some instructions for a dataset structure later on