MCPcopy Create free account
hub / github.com/atomicarchitects/equiformer_v2 / evaluate

Function evaluate

engine.py:110–141  ·  view source on GitHub ↗
(model, norm_factor, target, data_loader, device, amp_autocast=None, 
    print_freq=100, logger=None)

Source from the content-addressed store, hash-verified

108
109
110def evaluate(model, norm_factor, target, data_loader, device, amp_autocast=None,
111 print_freq=100, logger=None):
112
113 model.eval()
114
115 loss_metric = AverageMeter()
116 mae_metric = AverageMeter()
117 criterion = torch.nn.L1Loss()
118 criterion.eval()
119
120 task_mean = norm_factor[0] #model.task_mean
121 task_std = norm_factor[1] #model.task_std
122
123 with torch.no_grad():
124
125 for data in data_loader:
126 data = data.to(device)
127 #data.edge_d_index = radius_graph(data.pos, r=10.0, batch=data.batch, loop=True)
128 #data.edge_d_attr = data.edge_attr
129
130 with amp_autocast():
131 pred = model(f_in=data.x, pos=data.pos, batch=data.batch,
132 node_atom=data.z,
133 edge_d_index=data.edge_d_index, edge_d_attr=data.edge_d_attr)
134 pred = pred.squeeze()
135
136 loss = criterion(pred, (data.y[:, target] - task_mean) / task_std)
137 loss_metric.update(loss.item(), n=pred.shape[0])
138 err = pred.detach() * task_std + task_mean - data.y[:, target]
139 mae_metric.update(torch.mean(torch.abs(err)).item(), n=pred.shape[0])
140
141 return mae_metric.avg, loss_metric.avg
142
143
144def compute_stats(data_loader, max_radius, logger, print_freq=1000):

Callers

nothing calls this directly

Calls 2

updateMethod · 0.95
AverageMeterClass · 0.70

Tested by

no test coverage detected