Batch inconsistency in PINNs!!

48 views (last 30 days)
MAHSA YOUSEFI
MAHSA YOUSEFI on 24 Oct 2024 at 14:51
Commented: MAHSA YOUSEFI on 4 Nov 2024 at 12:12
Hi there!
Based on the following highlights extracted from this example:
X0 = [x0IC x0BC1 x0BC2]; %numBoundaryConditionPoints = [25 25];
T0 = [t0IC t0BC1 t0BC2]; %numInitialConditionPoints = 50;
points = rand(numInternalCollocationPoints,2); %numInternalCollocationPoints=10000
dataX = 2*points(:,1)-1;
dataT = points(:,2);
These mean:
  • dataX and dataT are column vectors of length 10000.
  • X0, and T0 are two row vectors of length 100, i.e. 50+25+25
The following dlarray formats make sense because of column vectors X, T and row vectors X0, T0.
X = dlarray(dataX,"BC");
T = dlarray(dataT,"BC");
X0 = dlarray(X0,"CB");
T0 = dlarray(T0,"CB");
What I cannot underestant from model function is these parts:
XT = cat(1,X,T); %====>???!!!
U = forward(net,XT);
and
XT0 = cat(1,X0,T0);
U0Pred = forward(net,XT0);
Shouldn't it be as below?
XT = cat(2,X,T);
U = forward(net,XT);
How it has been worked?
Thanks in advance for any clarification!

Accepted Answer

praguna manvi
praguna manvi on 29 Oct 2024 at 8:38
As I see, you are looking for an explanation of the function “cat(1, X, T)” which concatenates on dimension 1 for the following Physics-Informed Neural Network (PINN) example:
openExample('nnet/TrainPhysicsInformedNeuralNetworkWithLBFGSAndAutoDiffExample’)
In this example, the network expects input features of size “2C x 1B”, meaning 2 features with a batch size of “B”. You can visualize the network using:
analyzeNetwork(net)
In the example, the dimensions of “X”, “T”, “X0”, and “T0” are in the data format “1(C) x 10000(B) and 1(C) x 100(B)” respectively. Using “cat(1, X, T)”, you create an input feature of size “2(C) x 10000(B)”, which matches the feature input size expected by the neural network. On the other hand, “cat(2, X, T)” would create a size of “1(C) x 20000(B)” on dimension two.
For more information on data format and functions on “dlarray” refer to the following link:
  3 Comments
praguna manvi
praguna manvi on 4 Nov 2024 at 4:48
Edited: praguna manvi on 4 Nov 2024 at 4:49
@MAHSA YOUSEFI, the dimensions of "dataX" and "dataY" in the following lines of the example:
X = dlarray(dataX, "BC");
T = dlarray(dataT, "BC");
are 10000 x 1, which is read in the format as "BC". This results in "X" & "T" being "1(C) x 10000(B)". Therefore, we can concatenate them along dimension 1.
MAHSA YOUSEFI
MAHSA YOUSEFI on 4 Nov 2024 at 12:12
@praguna manvi I can see now!! The key point was then in "the software automatically permutes the dimensions such that the format has dimensions in the order: "S", ''C", "B", and .... ". I appreciate for your answer.

Sign in to comment.

More Answers (0)

Products


Release

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!