0299 STATIC RELEASE EXCERPTS
Commit ec433b46e64bf1ec7fef8814c626c36bef3b97aa; source-only archive SHA256 f6de9bd678ac591b00e96607c1ced5d6cf39cf13407e388c5cfae696e1c2c21f
Exact member lines, static reading only. Historical experiment correspondence not established.

FILE sources/0299/r01/CURVGT.py SHA256 bf9801a4dc5b6b6f64096bd8197650c9954884bef1deff56760f763054e980ce
LINES 50-61
50: edge_attr_path = f'./dataset/{datasets_function}/geometry_processed_docs/edge_attr.pt'
51: vec_normal_path = f'./dataset/{datasets_function}/geometry_processed_docs/vec_normal.pt'
52: grad_matrix_path = f'./dataset/{datasets_function}/geometry_processed_docs/gradMatrix.pt'
53: mass_path = f'./dataset/{datasets_function}/geometry_processed_docs/mass.pt'
54: vertex_to_voronoi_path = f'./dataset/{datasets_function}/geometry_processed_docs/vertexToVoronoi.txt'
55: boundary_vertices_path = f'./dataset/{datasets_function}/geometry_processed_docs/boundaryVertices.pt'
56: inv_metrics_path = f'./dataset/{datasets_function}/geometry_processed_docs/inv_metrics.pt'
57: pd_path = f'./dataset/{datasets_function}/geometry_processed_docs/PD.pt'
58: eigenvec_path = f'./dataset/{datasets_function}/geometry_processed_docs/normalized_eigenvec.pt'
59: 
60: train_data_path = f'./dataset/{datasets_function}/wrinkle/train_data(.1).pt'
61: test_data_path = f'./dataset/{datasets_function}/wrinkle/test_data(.1).pt'

LINES 95-109
95: max_voronoi_count = max(len(v) for v in vertices_to_voronoi)
96: vertices_to_voronoi_tensor = torch.full((len(vertices_to_voronoi), max_voronoi_count), -1, dtype=torch.long)
97: for i, voronoi_list in enumerate(vertices_to_voronoi):
98:     vertices_to_voronoi_tensor[i, :len(voronoi_list)] = torch.tensor(voronoi_list, dtype=torch.long)
99: mask = vertices_to_voronoi_tensor != -1  # mask contains True and False values
100: degree = mask.sum(dim=1).float().unsqueeze(1) #so that its shape is (|V|,1)
101: 
102: v_num = vertex_normals.shape[0]
103: e_num = edge_attrs.shape[0]
104: f_num = 4802
105: mu = 5
106: 
107: train_data, test_data = torch.load(train_data_path),torch.load(test_data_path)
108: train_loader = DataLoader(train_data, batch_size=batch_size, shuffle=False)
109: test_loader = DataLoader(test_data, batch_size=batch_size, shuffle=False)

LINES 181-210
181:         self.linear = Linear(3,3) 
182:         self.att = torch.nn.Parameter(torch.Tensor(heads, 2 * out_channels))
183:         self.treeMask = treeMasks
184: 
185:         self.k = torch.nn.Parameter(torch.ones(v_num, 3,3)).to(device) 
186:         self.attn = torch.nn.Parameter(torch.ones(v_num, 1,2,3)).to(device)
187:         self.k2 = torch.nn.Parameter(torch.ones(v_num, 3,3)).to(device)  
188: 
189:         mask = torch.zeros_like(self.k, dtype=torch.bool).to(device)
190:         mask[treeRoots] = True
191:         self.k.register_hook(lambda grad: grad * mask.float())
192: 
193:         mask2 = torch.zeros_like(self.attn, dtype=torch.bool).to(device)
194:         mask2[treeRoots] = True
195:         self.attn.register_hook(lambda grad: grad * mask2.float()) 
196: 
197:         mask3 =  torch.zeros_like(self.k2, dtype=torch.bool).to(device)
198:         mask3[treeRoots] = True
199:         self.k2.register_hook(lambda grad: grad * mask3.float()) 
200: 
201:         self.layernormA = nn.LayerNorm([e_num,3,2])
202:         self.layernormB = nn.LayerNorm([e_num,2])
203:         self.layernormC = nn.LayerNorm([e_num,2])
204:         
205:         self.broadcastmaps = broadcastmaps
206: 
207:         ###init para PT requires
208:         self.cur_k = self.k.repeat(batch_size, 1, 1)
209:         self.cur_attn = self.attn.repeat(batch_size, 1, 1,1)
210:         self.cur_k2 = self.k2.repeat(batch_size, 1, 1)

LINES 250-297
250:     def parallel_transport_unmasked(self, repeat_times,x_j):
251:         #PT with positive Gaussian curvature
252:         e1s, e2s, e3s =  self.e1s[:repeat_times*e_num],self.e2s[:repeat_times*e_num],self.e3s[:repeat_times*e_num]
253:         cos, sin = self.cos_unmasked[:repeat_times*e_num],self.sin_unmasked[:repeat_times*e_num]
254:         a, b = torch.einsum('ij,ij->i',e1s,x_j).view(-1,1),torch.einsum('ij,ij->i',e2s,x_j).view(-1,1)
255:         pt_ed = a*cos*e1s+a*sin*e3s+b*e2s
256:     
257:         #PT with negative Gaussian Curvature, projection along principal directions
258:         x_dir, y_dir = self.H2frame[:repeat_times*e_num,0], self.H2frame[:repeat_times*e_num,1]
259:         transform_matrix = self.transform_matrix[:repeat_times*e_num]
260:         cur_option_mask = self.option_mask[:repeat_times*e_num]
261:     
262:         a, b = torch.einsum('ij,ij->i',x_dir,x_j).view(-1,1),torch.einsum('ij,ij->i',y_dir,x_j).view(-1,1)
263:         local_coord = torch.cat((a,b),dim=-1)
264:         pt_ed2 = torch.einsum('ijk,ik->ij',transform_matrix, local_coord)
265: 
266:         pt_ed2 = x_dir*pt_ed2[:,0].unsqueeze(1) + y_dir * pt_ed2[:,1].unsqueeze(1)
267: 
268:         strictly_pos = (cur_option_mask == 1).long().unsqueeze(1)
269:         strictly_neg = (cur_option_mask == -1).long().unsqueeze(1)
270:         strictly_zero = (cur_option_mask == 0).long().unsqueeze(1)
271: 
272:         return pt_ed*strictly_pos + pt_ed2*strictly_neg + x_j*strictly_zero
273: 
274:     def parallel_transport_masked(self, repeat_times,x_j):
275:         e1s, e2s, e3s =  self.e1s[:repeat_times*e_num],self.e2s[:repeat_times*e_num],self.e3s[:repeat_times*e_num]
276:         cos, sin = self.cos_masked[:repeat_times*e_num],self.sin_masked[:repeat_times*e_num]
277:         a, b = torch.einsum('ij,ij->i',e1s,x_j).view(-1,1),torch.einsum('ij,ij->i',e2s,x_j).view(-1,1)
278:         pt_ed = a*cos*e1s+a*sin*e3s+b*e2s
279:     
280:         #PT with negative Gaussian Curvature, projection along principal directions
281:         x_dir, y_dir = self.H2frame[:repeat_times*e_num,0], self.H2frame[:repeat_times*e_num,1]
282:         transform_matrix = self.transform_matrix[:repeat_times*e_num]
283:         cur_option_mask = self.option_mask[:repeat_times*e_num]
284: 
285:         a, b = torch.einsum('ij,ij->i',x_dir,x_j).view(-1,1),torch.einsum('ij,ij->i',y_dir,x_j).view(-1,1)
286:         local_coord = torch.cat((a,b),dim=-1)
287:         pt_ed2 = torch.einsum('ijk,ik->ij',transform_matrix, local_coord)
288: 
289:         pt_ed2 = x_dir*pt_ed2[:,0].unsqueeze(1) + y_dir * pt_ed2[:,1].unsqueeze(1)
290:         #if masked, then the transform matrix degenerates into an identity matrix
291:         cur_tree_mask = self.treeMask.repeat(repeat_times).unsqueeze(1)
292:         pt_ed2 =  x_j*(cur_tree_mask+1)%2 + pt_ed2*cur_tree_mask
293: 
294:         strictly_pos = (cur_option_mask == 1).long().unsqueeze(1)
295:         strictly_neg = (cur_option_mask == -1).long().unsqueeze(1)
296:         strictly_zero = (cur_option_mask == 0).long().unsqueeze(1)
297:         return pt_ed*strictly_pos + pt_ed2*strictly_neg + x_j*strictly_zero

LINES 299-350
299:     def message(self, x_i, x_j, edge_index):
300:         repeat_times = edge_index.shape[1]//(edge_attrs.shape[0])
301: 
302:         pt = self.parallel_transport_unmasked(repeat_times,x_j)
303:         if not self.isComplete and not self.isYoung:
304:             cur_broadcastmaps = self.cur_broadcastmaps[:repeat_times*e_num]
305: 
306:             extN = vertex_normals.repeat(batch_size, 1)
307:             def proj_back(z):
308:                 projection = torch.einsum('ij,imj->im', extN, z)
309:                 return z- (projection * extN).unsqueeze(1)
310: 
311:             cur_k = self.cur_k[:repeat_times*e_num]
312:             cur_k = proj_back(cur_k)
313:             broadcast = torch.stack([self.parallel_transport_masked(repeat_times,cur_k[edge_index[0]][:,i,:]) for i in range(3)],dim=-1)[cur_broadcastmaps]
314:             for _ in range(3): #broadcast 3+1 times in total
315:                 broadcast = torch.stack([self.parallel_transport_masked(repeat_times,broadcast[:,i,:]) for i in range(3)], dim=-1)[cur_broadcastmaps]
316: 
317:             g, pds = metrics.repeat(repeat_times,1,1)[edge_index[1]], PD.repeat(repeat_times,1,1)[edge_index[1]]
318:             a = torch.einsum('ijk,ikl->ijl',pds, broadcast/broadcast.norm()).transpose(1,2)
319:             b = torch.einsum('ijk,ik->ij',pds,pt)
320: 
321:             final_pt = torch.einsum('ijk,ij,ik->i',g,a[:,0],b)
322:             final_pt = final_pt.unsqueeze(-1)*broadcast[:,1]
323:             
324:             cur_attn = self.cur_attn[:repeat_times*e_num]
325: 
326:             broadcast = torch.stack([self.parallel_transport_masked(repeat_times,cur_attn[edge_index[0]][:,i,0,:]) for i in range(1)],dim=-1)[cur_broadcastmaps]
327:             for _ in range(3): #broadcast 3+1 times in total
328:                 broadcast = torch.stack([self.parallel_transport_masked(repeat_times,broadcast[:,i,:]) for i in range(1)], dim=-1)[cur_broadcastmaps]
329:             
330:             a1 = torch.einsum('ijk,ikl->ijl',pds, broadcast/broadcast.norm()).transpose(1,2)
331: 
332:             broadcast = torch.stack([self.parallel_transport_masked(repeat_times,cur_attn[edge_index[0]][:,i,1,:]) for i in range(1)],dim=-1)[cur_broadcastmaps]
333:             for _ in range(3): #broadcast 3+1 times in total
334:                 broadcast = torch.stack([self.parallel_transport_masked(repeat_times,broadcast[:,i,:]) for i in range(1)], dim=-1)[cur_broadcastmaps]
335:             a2 = torch.einsum('ijk,ikl->ijl',pds, broadcast/broadcast.norm()).transpose(1,2)            
336: 
337:             a1 = a1/a1.norm()
338:             a2 = a2/a2.norm()
339: 
340:             attn = torch.stack([a1,a2], dim=-2).view(-1,2,2)
341: 
342:             b1 = torch.einsum('ijk,ik->ij',pds,x_i)
343:             b2 = torch.einsum('ijk,ik->ij',pds,pt)
344:         
345:             alpha1, alpha2 = torch.einsum('ijk,ij,ik->i',g,b1, attn[:,0]), torch.einsum('ijk,ij,ik->i',g,b2, attn[:,1])
346:             alpha = self.linear1(torch.stack([alpha1,alpha2], dim=-1)).flatten()
347:             
348:             alpha = softmax(alpha, edge_index[0])
349: 
350:             return final_pt * alpha.unsqueeze(-1) 

LINES 377-411
377:     def update(self, aggr_out, x,edge_index=None):
378:         repeat_times = edge_index.shape[1]//(edge_attrs.shape[0]) 
379:         cur_broadcastmaps = self.cur_broadcastmaps[:repeat_times*e_num]
380: 
381:         extN = vertex_normals.repeat(batch_size, 1)
382:         def proj_back(z):
383:             projection = torch.einsum('ij,imj->im', extN, z)
384:             return z- (projection * extN).unsqueeze(1)
385:         
386:         cur_k = self.cur_k2[:repeat_times*e_num]
387:         
388:         cur_k = proj_back(cur_k)
389:         broadcast = torch.stack([self.parallel_transport_masked(repeat_times,cur_k[edge_index[0]][:,i,:]) for i in range(3)],dim=-1)[cur_broadcastmaps]
390:         for _ in range(3): #broadcast 3+1 times in total
391:             broadcast = torch.stack([self.parallel_transport_masked(repeat_times,broadcast[:,i,:]) for i in range(3)], dim=-1)[cur_broadcastmaps]
392:         
393:         x = x[edge_index[1]]
394: 
395:         g, pds = metrics.repeat(repeat_times,1,1)[edge_index[1]], PD.repeat(repeat_times,1,1)[edge_index[1]]
396:         a = torch.einsum('ijk,ikl->ijl',pds, broadcast/broadcast.norm()).transpose(1,2)
397:         b = torch.einsum('ijk,ik->ij',pds,x)
398: 
399:         final = torch.einsum('ijk,ij,ik->i',g,a[:,0],b)
400:         final = final.unsqueeze(-1)*broadcast[:,1]
401:         final = scatter(final, edge_index[1], dim=0, dim_size=v_num*repeat_times, reduce='mean')
402: 
403:         extN = vertex_normals.repeat(final.shape[0]//v_num, 1)
404:         final =  final- (torch.einsum('ij,ij->i', extN, final).unsqueeze(-1) * extN)
405: 
406:         the_end = True
407:         if the_end: 
408:             b = torch.einsum('ijk,ik->ij',PD.repeat(repeat_times,1,1),self.c[0]*final+self.c[1]*aggr_out)
409:             final = torch.einsum('ijk,ij,ik->i',g,a[:,2],b[edge_index[1]])
410:             final = scatter(final, edge_index[1], dim=0, dim_size=v_num*repeat_times, reduce='mean')
411:             return final.unsqueeze(-1).repeat(1,3)

LINES 556-565
556: 
557:             ################## without modes
558:             if datasets_function == 'datasets_wave':
559:                 vector_fields = (extG @  x[:,0]).view(-1, 3)
560:                 vector_fields = torch.sum(vector_fields[ext_vertices_to_voronoi_tensor, :] * ext_mask.unsqueeze(2).repeat(1, 1, 3), dim=1)
561:                 vector_fields /= ext_degree.repeat(1, 3)
562: 
563:                 V0 = self.CURVGT(vector_fields.view(-1, 3), edge_index, istraining)
564:                 V0 = self.linear(V0).view(-1, 1)
565:                 V0 = self.layernorm1(V0.view(current_batchsize,-1,1)).view_as(V0)

LINES 659-691
659: def one_go(model_type=f"{model_name}"):
660:     model = CURVGT(model_type=model_type).to(device)
661:     best_model = model.state_dict()
662:     best_loss = 1e9
663: 
664:     optimizer = torch.optim.Adam(model.parameters(), lr=learning_rate)
665:     def L2Criterion(y,y_pred, mu=0):
666:         current_batchsize = y.shape[0]//M.shape[0]
667:         weighted_mse_loss = (y-y_pred).transpose(1,0) @ torch.block_diag(*[M]*current_batchsize) @ (y-y_pred)  
668:         boundary_loss = torch.sum(boundary_mask.repeat(current_batchsize)*(y-y_pred).flatten()**2)
669:         return weighted_mse_loss + mu * boundary_loss
670:     def L2Criterion2(y,y_pred,mu=0):
671:         current_batchsize = y.shape[0]//M.shape[0]
672:         return  (y-y_pred).transpose(1,0) @ torch.block_diag(*[M]*current_batchsize) @ (y-y_pred)  
673:     
674:     def H1Criterion(y,y_pred,mu=0):
675:         current_batchsize = y.shape[0]//M.shape[0]
676:         extG, extM = torch.block_diag(*[G for _ in range(current_batchsize)]), torch.block_diag(*[M for _ in range(current_batchsize)])
677: 
678:         ext_vertices_to_voronoi_tensor = vertices_to_voronoi_tensor.repeat(current_batchsize, 1)
679:         incre_mask = (ext_vertices_to_voronoi_tensor != -1).long()
680:         incre = torch.concat([torch.ones_like(vertices_to_voronoi_tensor) * vertices_to_voronoi_tensor.shape[0] * i for i in range(current_batchsize)], dim=0).long()
681:         ext_vertices_to_voronoi_tensor += incre_mask*incre
682:         
683:         delta_y = y-y_pred
684:         delta = (extG@delta_y).view(-1,3)
685:         delta = delta[ext_vertices_to_voronoi_tensor,:]
686:         delta = torch.mean(delta,dim=1)
687:         delta = torch.sum(delta*delta,dim=-1).unsqueeze(1)
688: 
689:         h1_loss = torch.sum(extM @ delta).view(-1,1) 
690:         l2_loss = delta_y.transpose(1,0) @ extM @ delta_y   
691:         return h1_loss+l2_loss

LINES 782-812
782:     train_losses = []
783:     train_epoch = 300
784:     best_epoch = -1
785: 
786:     for epoch in range(0, train_epoch):
787:         train_loss = train()
788: 
789:         if torch.isnan(torch.tensor(train_loss)).any():
790:             raise ValueError("NAN")
791:     
792:         scheduler.step()
793:     
794:         train_losses.append(train_loss)
795:     
796:         if train_loss < best_loss:
797:             best_loss = train_loss
798:             best_epoch = epoch
799:             torch.save(model.state_dict(), f'./dataset/{datasets_function}/best_model/best_model_{model_name}.pt')
800: 
801:         if epoch % 1 == 0:
802:             test_loss_H1, test_loss_L2 = test_H1(), test_L2()
803:             print(f'({model_name})Epoch {epoch}, Train Loss: {train_loss:.8f}, Test Loss(H1): {test_loss_H1:.8f}, Test Loss(L2): {test_loss_L2:.8f}')
804:     
805:     best_model = torch.load(f'./dataset/{datasets_function}/best_model/best_model_{model_name}.pt')
806:     model.load_state_dict(best_model)
807:     print(f"-----------------({model_name})(best_epoch, best_train_loss):", best_epoch, best_loss)
808:     
809:     final_test_loss_H1 = test_H1()
810:     final_test_loss_L2 = test_L2()
811: 
812:     return torch.tensor(train_losses).view(1, -1), best_model, final_test_loss_H1, final_test_loss_L2

LINES 823-846
823:     def L2Criterion(y, y_pred, mu=0):
824:         current_batchsize = y.shape[0] // M.shape[0]
825:         weighted_mse_loss = (y - y_pred).transpose(1, 0) @ torch.block_diag(*[M] * current_batchsize) @ (y - y_pred)
826:         boundary_loss = torch.sum(boundary_mask.repeat(current_batchsize) * (y - y_pred).flatten() ** 2)
827:         return weighted_mse_loss + mu * boundary_loss
828: 
829:     def H1Criterion(y, y_pred, mu=0):
830:         current_batchsize = y.shape[0] // M.shape[0]
831:         extG, extM = torch.block_diag(*[G for _ in range(current_batchsize)]), torch.block_diag(*[M for _ in range(current_batchsize)])
832: 
833:         ext_vertices_to_voronoi_tensor = vertices_to_voronoi_tensor.repeat(current_batchsize, 1)
834:         incre_mask = (ext_vertices_to_voronoi_tensor != -1).long()
835:         incre = torch.concat([torch.ones_like(vertices_to_voronoi_tensor) * vertices_to_voronoi_tensor.shape[0] * i for i in range(current_batchsize)], dim=0).long()
836:         ext_vertices_to_voronoi_tensor += incre_mask * incre
837:         
838:         delta_y = y - y_pred
839:         delta = (extG @ delta_y).view(-1, 3)
840:         delta = delta[ext_vertices_to_voronoi_tensor, :]
841:         delta = torch.mean(delta, dim=1)
842:         delta = torch.sum(delta * delta, dim=-1).unsqueeze(1)
843: 
844:         h1_loss = torch.sum(extM @ delta).view(-1, 1)
845:         l2_loss = delta_y.transpose(1, 0) @ extM @ delta_y
846:         return h1_loss + l2_loss

LINES 866-885
866: 
867:             output = model(data, istraining=False)  # Get model output
868:             
869:             # Compute losses
870:             loss_H1 = H1Criterion(output, data.y.unsqueeze(1))
871:             loss_L2 = L2Criterion(output, data.y.unsqueeze(1))
872: 
873:             total_loss_H1 += loss_H1.item()
874:             total_loss_L2 += loss_L2.item()
875:             graph_cnt += output.shape[0] // M.shape[0]
876: 
877:     # Calculate average losses
878:     avg_loss_H1 = total_loss_H1 / graph_cnt
879:     avg_loss_L2 = total_loss_L2 / graph_cnt
880: 
881:     print(f"Evaluation Results for {model_name}:")
882:     print(f"Avg Test Loss (H1): {avg_loss_H1:.8f}")
883:     print(f"Avg Test Loss (L2): {avg_loss_L2:.8f}")
884: 
885:     return avg_loss_H1, avg_loss_L2  # Return evaluation results

FILE sources/0299/r01/graphTransformers.py SHA256 08abb50ce5369237fecd56767ac15f855d98f8bd477bf9db8980b6e4a36b8c05
LINES 10-40
10: class SelfAttention(nn.Module):
11:     def __init__(self, input_dim, heads):
12:         super(SelfAttention, self).__init__()
13:         self.heads = heads
14:         self.head_dim = input_dim // heads
15:         
16:         self.query = nn.Linear(input_dim, input_dim)
17:         self.key = nn.Linear(input_dim, input_dim)
18:         self.value = nn.Linear(input_dim, input_dim)
19:         self.fc_out = nn.Linear(input_dim, input_dim)
20:         
21:     def forward(self, value, key, query, mask=None):
22:         batch_size = query.shape[0]
23:         
24:         Q = self.query(query).view(batch_size, -1, self.heads, self.head_dim).transpose(1, 2)
25:         K = self.key(key).view(batch_size, -1, self.heads, self.head_dim).transpose(1, 2)
26:         V = self.value(value).view(batch_size, -1, self.heads, self.head_dim).transpose(1, 2)
27: 
28:         energy = torch.matmul(Q, K.transpose(-2, -1)) / math.sqrt(self.head_dim)  # (batch_size, heads, seq_len, seq_len)
29:         
30:         if mask is not None:
31:             energy = energy.masked_fill(mask == 0, float('-inf'))
32:         
33:         attention = torch.softmax(energy, dim=-1)  # (batch_size, heads, seq_len, seq_len)
34:         
35:         out = torch.matmul(attention, V)  # (batch_size, heads, seq_len, head_dim)
36:         out = out.transpose(1, 2).contiguous().view(batch_size, -1, self.heads * self.head_dim)
37: 
38:         out = self.fc_out(out)  # (batch_size, seq_len, input_dim)
39:         
40:         return out

LINES 279-299
279: class TransformerLayer_GT(nn.Module):
280:     def __init__(self, input_dim, heads, hidden_dim, output_dim, dropout=0.1):
281:         super(TransformerLayer_GT, self).__init__()
282:         self.attention = SelfAttention(input_dim, heads)
283:         self.fourierAttention = SimpleAttention(d_model=input_dim,n_head=heads,attention_type='fourier')
284:         self.galerkinAttention = SimpleAttention(d_model=input_dim,n_head=heads,attention_type='galerkin')
285: 
286:         self.feed_forward = FeedForward(input_dim, hidden_dim, output_dim)
287:         
288:         self.layernorm1 = nn.LayerNorm([input_dim])
289:         self.layernorm2 = nn.LayerNorm([input_dim])
290:         
291:         self.dropout = nn.Dropout(dropout)
292:         
293: 
294:     def forward(self, x, mask=None):
295:         attention_out = self.attention(x, x, x)
296:         x = self.layernorm1(x + self.dropout(attention_out).view(x.shape[0],-1))  # Add & Norm
297:         ff_out = self.feed_forward(x)
298:         x = self.layernorm2(x + self.dropout(ff_out))  # Add & Norm
299:         return x

FILE sources/0299/r01/README.md SHA256 de52a047aa6ea61e08f31a4be85f947d4b1972b09a83fb8e327b1f1767aa8361
LINES 24-35
24: ---
25: The main body of our model lies in `CURVGT.py` while some auxilary classes reside in `graphtransformers.py` and `ResNet.py`. Geometry processed documents like normal vectors, Gaussian curvature and parameters to support parallel transport are all in the folder `geometry_processed_docs`. Stuffs to support sub-tree partition mechanism are in the folder `sub_tree_partitions`. The train set and test set are in the folder `wrinkle`. The weights of the best-performing model are saved in the `best_model` directory.
26: 
27: ### Quick Start
28: ---
29: A trained model is provided. You can load the parameters and run the test function by simply typing in the command:
30: 
31: `python CURVGT.py --model_name CURVGT --datasets_function datasets_wave --datasets wrinkles --batch_size 20 --gpu 0 --test_pattern 0`
32: 
33: You can also choose to train the model by:
34: 
35: `python CURVGT.py --model_name CURVGT --datasets_function datasets_wave --datasets wrinkles --batch_size 20 --gpu 0 --test_pattern 1`

LINES 69-85
69:   - **Default**: 0
70: 
71: ### Further Illustration of Geometry Processed Documents
72: ---
73: Documents unmentioned here are not lerveraged in our implementation. 
74: - `GaussianCurvature.pt`: Each node is assigned with a scalar, standing for the Gaussian curvature estimate down there. We leverage a mask (`option_mask.pt`) to decide the correct parallel transport (Euclidean, spheric and hyperbolic). Thus three types of parallel transport are runned simultaneously and one can further optimize this to accelerate. To fetch these curvature estimates $\kappa$, we use an excellent open geometry process C++ library `libigl` where these estimates along with the principal direction of curvature are also available. Only mesh documents in common formats `.obj`, `.off` etc are needed. Then the `option_mask` flags the type of space embedded in: `+1` for $\kappa>\varepsilon$ (spheric), `-1` for $\kappa < -\varepsilon$ (hyperbolic) and otherwise `0` for Euclidean.
75: 
76: - `H2frame.pt` and `HyperPT.pt`: Edge-wise parameters to support parallel transport on embedding hyperbloic spaces. The concrete formulae can be found in the paper and the appendix. We mention that `H2frame.pt` contain two 3D vectors at each point with positive and negative principal curvature respectively, which can also be obtained in `libigl`. `HyperPt.pt` involves the works to compute the parallel transport on $\mathbb H^2$ as mentioned in the paper. For each vertex $v$, we place it on $(0,1)$ in $\mathbb H^2$ and note that two coordinate-axes are exactly two principal directions. This observation guides us how to place $v$'s neighbors around $v$ on $\mathbb H^2$. In the sense of isometric geodesic embedding, assume two vertices $u$ and $v$ are with 3D coordinates $\mathbf x_u$ and $\mathbf x_v$, then we project $\mathbf x_v-\mathbf x_u$ back to the estimated tangent plane $T_u\mathcal M$ at $\mathbf x_u$. This tangent plane can be estimated by various ways, the most famous and simple one is via PCA(Principle Component Anaysis). Then this projected tangent vector on $\mathcal M$(or more exactly, the pseudo sphere) can be mapped to the tangent vector in $\mathbb H^2$, denoted by $\mathbf p$. With exponential map in $\mathbb H^2$, one can find a unique geodesic starting at $(0,1)$ with velocity $\mathbf p$. Consequently, the neighbor falls on this geodesic (either a line parallel to $y$-axis or a semicircle centered at the $x$-axis). We choose the one such that the hyperbolic distance equaling their Euclidean counterpart $||\mathbf x_u-\mathbf{x}_v||_2^2$. 
77:    
78: - `edge_attr.pt`: Edge-wise parameters to support parallel transport on embedding spherical spaces. The sphere case is similar to the hyperbolic one. One can get them by serveral steps: (i) find the tangent plane; (ii) estimate the tangent vector via projection; (iii) find the geodesic begining at this point with the direction along this tangent vector; (iv) determine the exact point on this geodesic such that the spherical distance equals the Euclidean counterpart.
79: 
80: The following ones can be gained easily by simpily calling APIs offered by `libigl`:
81: - `gradMatrix.pt`: the discrete gradient operator. 
82: - `mass.pt`: the surface area that a point takes up.
83: - `vec_normal.pt`, `PD.pt`: the normal vector field and principal directions at each node. The latter forms a local coordinate frame. Parallel transport should be computed based on concrete frames while feature updates are frame-independent (they are scalar).
84: 
85: **More Implementation Details**. We use principal directions as a coordinate chart on the surface. It may degenerate sometimes when the curvature tensor is isotropic (e.g., a sphere). But in most cases, these irregular points are rare and can be fixed via interpolations with the neighbors. Each time we compute message passing on surfaces, we project the 3D vectors onto the 2D tangent planes embedded in $\mathbb R^3$, whose these 2D coordinate components are served as inputs and outputs of the network, and transform them back to 3D ones if necessary. This approach makes the entire process working on the embedded manifold, which is independent of the 3D space it embeds in.
