MCPcopy Create free account
hub / github.com/TPCD/DCCL / Truncated_initializer

Function Truncated_initializer

model/meta_graph.py:5–13  ·  view source on GitHub ↗
(m)

Source from the content-addressed store, hash-verified

3import numpy as np
4from torch.nn import functional as F
5def Truncated_initializer(m):
6 # sample u1:
7 size = m.size()
8 u1 = torch.rand(size)*(1-np.exp(-2)) + np.exp(-2)
9 # sample u2:
10 u2 = torch.rand(size)
11 # sample the truncated gaussian ~TN(0,1,[-2,2]):
12 z = torch.sqrt(-2*torch.log(u1)) * torch.cos(2*np.pi*u2)
13 m.data = z
14
15
16class GraphConvolution(nn.Module):

Callers 3

__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85

Calls 1

logMethod · 0.45

Tested by

no test coverage detected