cf1cc19bb79ae4128ef5437279de475835374a46,benchmark/runtime/dgl/train.py,,train_runtime,#Any#Any#Any#Any#,9
Before Change
def train_runtime(Net, data, epochs, device):
g = DGLGraph(data.graph)
g.set_n_initializer(dgl.init.zero_initializer)
x = torch.tensor(data.features, dtype=torch.float, device=device)
mask = torch.tensor(data.train_mask, dtype=torch.uint8, device=device)
y = torch.tensor(data.labels, dtype=torch.long, device=device)[mask]
g.add_edges(g.nodes(), g.nodes())
norm = torch.pow(g.in_degrees().float(), -0.5)
norm[torch.isinf(norm)] = 0
g.ndata["norm"] = norm.unsqueeze(1).to(device)
model = Net(g, x.size(1), data.num_labels).to(device)
After Change
def train_runtime(model, data, epochs, device):
if hasattr(data, "features"):
x = torch.tensor(data.features, dtype=torch.float, device=device)
else:
x = None
mask = data.train_mask if hasattr(data, "train_mask") else data.train_idx
y = torch.tensor(data.labels, dtype=torch.long, device=device)[mask]
model = model.to(device)
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 6
Instances
Project Name: rusty1s/pytorch_geometric
Commit Name: cf1cc19bb79ae4128ef5437279de475835374a46
Time: 2019-03-19
Author: matthias.fey@tu-dortmund.de
File Name: benchmark/runtime/dgl/train.py
Class Name:
Method Name: train_runtime
Project Name: catalyst-team/catalyst
Commit Name: aab3902d4a7d55f5a86058854adc36b8a12c873f
Time: 2019-05-20
Author: ekhvedchenya@gmail.com
File Name: catalyst/dl/callbacks/base.py
Class Name: OptimizerCallback
Method Name: on_batch_end