code stringlengths 3 6.57k |
|---|
len(z) |
len(x) |
len(z) |
dot(dot((z - x) |
inv(sigma) |
power(2.0 * pi, len(z) |
sqrt(det(sigma) |
exp(tmp) |
simpleMultivariateNormalPdf(z, detFactorSigma) |
factorized (real) |
len(z) |
exp(-0.5 * dot(z, z) |
power(2.0 * pi, dim / 2.) |
multivariateCauchy(mu, sigma, onlyDiagonal=True) |
svd(sigma) |
sqrt(s) |
diag(sigma) |
rand(len(mu) |
tan(pi * (r - 0.5) |
dot(d, dot(res, u) |
approxChiFunction(dim) |
Chi (expectation of the length of a normal random vector) |
float(dim) |
sqrt(dim) |
sqrtm(M) |
real_if_close(expm2(0.5 * logm(M) |
return (r + r.T) |
Copyright (c) |
range(1, 100) |
list(range(12, 64) |
setup_and_get_device(rank, world_size, nonce=0) |
os.environ.get("SLURM_NTASKS") |
str(7440 + nonce) |
int(os.environ.get("SLURM_LOCALID") |
dist.init_process_group(backend="gloo", rank=rank, world_size=world_size) |
rank (if you have 2 nodes with 8 GPUs each, you will have two "cuda:0" devices) |
str(rank) |
str(world_size) |
cleanup() |
dist.destroy_process_group() |
ToyModel(nn.Module) |
__init__(self) |
super(ToyModel, self) |
__init__() |
nn.Linear(10, 10) |
nn.ReLU() |
nn.Linear(10, 5) |
forward(self, x) |
self.net2(self.relu(self.net1(x) |
demo_basic(rank, world_size, weight, dp, noise_multiplier=0, max_grad_norm=1e8) |
torch.manual_seed(rank) |
print(f"Running basic DDP {withdp} differential privacy example on rank {rank}.") |
setup_and_get_device(rank, world_size) |
ToyModel() |
to(device) |
print(f"Initial weight: {model.net1.weight.data}") |
DPDDP(model) |
engine._set_seed(0) |
DDP(model, device_ids=[device]) |
nn.MSELoss() |
optim.SGD(ddp_model.parameters() |
engine.attach(optimizer) |
optimizer.zero_grad() |
torch.randn(batch_size, 5) |
to(device) |
ddp_model(torch.randn(batch_size, 10) |
to(device) |
loss_fn(outputs, labels) |
backward() |
optimizer.step() |
weight.copy_(model.net1.weight.data.cpu() |
cleanup() |
demo_ddp_hook(rank, world_size, weight, dp, noise_multiplier, max_grad_norm) |
torch.manual_seed(rank) |
print(f"Running DDP hook {withdp} differential privacy example on rank {rank}.") |
setup_and_get_device(rank, world_size, nonce=1) |
ToyModel() |
to(device) |
DDP(model, device_ids=[device]) |
engine._set_seed(0) |
nn.MSELoss() |
optim.SGD(ddp_model.parameters() |
engine.attach(optimizer) |
optimizer.zero_grad() |
torch.randn(batch_size, 5) |
to(device) |
ddp_model(torch.randn(batch_size, 10) |
to(device) |
loss_fn(outputs, labels) |
backward() |
optimizer.step() |
weight.copy_(model.net1.weight.data.cpu() |
cleanup() |
setup_and_get_device(rank, world_size, nonce=2) |
ToyModel() |
to(device) |
nn.parallel.DistributedDataParallel(model, device_ids=[device]) |
optim.SGD(ddp_model.parameters() |
engine.attach(optimizer) |
engine.module.parameters() |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.