Comments (3)
We did nothing fancy but using a timer to measure the model inference time. We mimic an online setting as in Figure 2 to infer one node at a time. We repeat the procedure 10 times to reduce the variance from randomly chosen nodes. The timing function we used is the following.
https://pytorch.org/docs/stable/benchmark_utils.html
from graphless-neural-networks.
Below are the functions I wrote for time measurement. Note that the results could be different from our paper as they depend on your hardware.
def sage_inference(model, feats, dataloader):
for step, (input_nodes, output_nodes, blocks) in enumerate(dataloader):
model(blocks, feats[input_nodes])
def sage_measure(conf, model_name, L, prune_budget=0.5, fan_out=None):
conf = copy.copy(conf)
conf['model_name'] = model_name
if model_name == 'SAGE':
get_model = lambda conf: Model(conf).encoder
elif model_name == 'SAGEQuantize':
get_model = lambda conf: torch.quantization.quantize_dynamic(Model(conf).encoder)
elif model_name == 'SAGEPrune':
conf['hidden_dim'] = int(conf['hidden_dim'] * prune_budget)
get_model = lambda conf: Model(conf).encoder
gnn_dur = []
for l in range(1, L+1):
conf['num_layers'] = l
set_seed(0)
model = get_model(conf)
sampler = dgl.dataloading.MultiLayerNeighborSampler([fan_out] * model.num_layers)
model.eval()
with torch.no_grad():
dur = []
for exp in range(num_exp):
set_seed(exp)
idx = torch.randperm(g.num_nodes())[0]
dataloader = dgl.dataloading.NodeDataLoader(g, idx, sampler, batch_size=batch_size, shuffle=False, drop_last=False)
t0 = benchmark.Timer(
stmt='sage_inference(model, feats, dataloader)',
setup='from __main__ import sage_inference',
globals={'model': model, 'feats': feats, 'dataloader': dataloader})
measurement = t0.blocked_autorange(min_run_time=0.2)
dur += [measurement.median * 1000]
gnn_dur += [np.mean(dur)]
return gnn_dur
from graphless-neural-networks.
Thx for your quick reply!
from graphless-neural-networks.
Related Issues (8)
- A paper that copy your paper [一篇论文洗稿您的论文]
- The problem of inference time HOT 2
- Cannot reproduce the results even with the same random seed HOT 2
- Failed to build environment HOT 1
- The function graph_split() seems to contradict the inductive scenarios. HOT 2
- Error Unpickling the Cora.npz data (and others) HOT 1
- About min-cut HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphless-neural-networks.