Adding 3D Electrostatics SciML example#21
Adding 3D Electrostatics SciML example#21mmarkows17 wants to merge 1 commit intomatlab-deep-learning:mainfrom
Conversation
conordaly0
left a comment
There was a problem hiding this comment.
Looks great Mae!
We need to remember to update the outer repo README as well to reference this example
| @@ -0,0 +1,9 @@ | |||
| function x = edge_to_node_accumulation(x,xe,B) | |||
There was a problem hiding this comment.
Here and elsewhere, I'd prefer us to use lower camel case -- e.g. edgeToNodeAccumulation rather than snake case.
Where I spot it in other files I'll just leave a comment saying prefer lower camel case.
| @@ -0,0 +1,11 @@ | |||
| function data = loadAllData(dataRootDir) | |||
There was a problem hiding this comment.
It looks like all the M-code files throughout each namespace are missing copyright headers. You should add one to each file.
| @@ -0,0 +1,10 @@ | |||
| function p = initialize_mlp(inputSize,hiddenSize,numLayers) | |||
There was a problem hiding this comment.
Prefer lower camel case initializeMLP
| @@ -0,0 +1,11 @@ | |||
| function p = initialize_processor(cfg) | |||
There was a problem hiding this comment.
Prefer lower camel case initializeProcessor
| @@ -0,0 +1,35 @@ | |||
| function [X,Xe,B,Y] = minibatch(X,Xe,B,Y,useGpu) | |||
| @@ -0,0 +1,562 @@ | |||
| %[text] # Rapid Design Exploration for a 3D Electrostatics Problem Using Transolver | |||
There was a problem hiding this comment.
I think this script could have a more descriptive name like electrostaticsUsingTransolver.
| XBatch = dlarray(single(paddedInputsTrain(:,:,bIdx)),"CSB"); | ||
| mBatch = dlarray(single(maskTrain(:,:,bIdx)),"CSB"); | ||
| VBatch = dlarray(single(paddedTargetsTrain(:,:,bIdx)),"CSB"); | ||
| EBatch = dlarray(single(paddedEfieldTrain(:,:,bIdx)),"CSB"); |
There was a problem hiding this comment.
The case to single should really be happening outside of the trainnig loop -- so that it is not repeated at every iteration.
|
|
||
| [net,avgGrad,avgSqGrad] = adamupdate(net,gradients,avgGrad,avgSqGrad,iteration,lr); | ||
|
|
||
| lossHistory(iteration) = double(extractdata(loss)); |
There was a problem hiding this comment.
I don't think it is necessary to cast to double here?
| if useGpu | ||
| V = predict(net,dlarray(gpuArray(normU)),gpuArray(ones(1,size(normU,2))),InputDataFormats=["CS","CS"]); | ||
| V = extractdata(V); | ||
| V = gather(V); | ||
| else | ||
| V = predict(net,dlarray(normU),ones(1,size(normU,2)),InputDataFormats=["CS","CS"]); | ||
| V = extractdata(V); | ||
| end |
There was a problem hiding this comment.
I'd advise using the if branch just to send the data to the GPU. Then the subsequent calls to predict, extract and gather can be combined for both branches.
| @@ -0,0 +1,74 @@ | |||
| # Rapid Design Exploration with Neural PDE Surrogates | |||
There was a problem hiding this comment.
Could we generate markdown from one or both of the transolver/meshgraphnet examples and find a way to include it in the repo, either in this readme or separate markdowns? I think it's important for examples to be readable on GitHub without requring someone to clone the repo and open the files in MATLAB just to read what the examples are doing.
Demo which shows how to create neural surrogate models for 3D field prediction directly from geometry/design.