A Mesh Quality Evaluation Neural Network Based on Dynamic Graph Attention
-
model.py- Contains the main neural network architectureDeepGCNLayer: Custom graph convolutional layer with residual connectionsDeeperGCN: Main model implementing a deep graph convolutional networkTraceModel: Wrapper for model tracing and deployment
-
preprocess.py- Mesh preprocessing and graph conversion utilitiesgrd2vertex_graph(): Converts 2D GRD meshes to vertex-based graphsgrd2element_graph(): Converts 2D GRD meshes to element-based graphscompute_proximity_adjacency(): Creates adjacency matrices based on spatial proximitypreprocess_grd_meshes(): Batch processing for GRD files
-
mesh_dataset.py- Dataset classes for mesh data loadingMeshDataset: Standard dataset class for larger datasetsgrd_label(): Label generation function for GRD files
-
utils.py- Training and utility functionstrain_model(): Complete training loop with validation and early stoppingtest_model(): Model evaluation functionsplit_dataset(): Dataset splitting utilitiessave_model(): Model checkpointingadd_weight_decay(): Optimizer configuration
from mesh_dataset import MeshDataset
from model import DeeperGCN
from utils import train_model
# Create dataset
dataset = MeshDataset(root='data', raw_file_root='processed',
num=1024, label_func=grd_label)
# Initialize model
model = DeeperGCN(input_channels=6, num_layers=4, hidden_channels=12,
num_classes=8, dropout=0.01)
from utils import train_model,add_weight_decay,\
split_dataset,test_model,print_results,save_model
train_data , val_data ,test_data = split_dataset(mesh)
add_weight_decay(model=model,weight_decay=0.0001)
train_model(model=model, optimizer=torch.optim.Adam(model.parameters(), lr=0.01,amsgrad=True),
criterion=nn.CrossEntropyLoss(),train_loader=DataLoader(train_data,batch_size=32, shuffle=True),
val_loader=DataLoader(val_data,batch_size=32, shuffle=True),epochs=5000,patience=25,writer=writer,
lr_scheduler=torch.optim.lr_scheduler.ReduceLROnPlateau(torch.optim.Adam(model.parameters()), mode='max',
factor=0.1,
patience=10, verbose=True, threshold=0.0001,
threshold_mode='rel', cooldown=0, min_lr=1e-09,
eps=1e-09),
grad_clipping_value=torch.nn.utils.clip_grad_norm(model.parameters(), 20, norm_type=2))- Python 3.8+
- PyTorch 1.12.1+ (with CUDA support recommended)
- PyTorch Geometric 2.0.4+