Blocks that compose the `Model`.
Miscellaneous¶
class RandomWalk(nn.Module):
def __init__(self, n, breaks):
super().__init__()
self.w = nn.Parameter(torch.randn(n,1))
self.breaks = breaks
def forward(self, x):
w = F.softplus(self.w.cumsum(0))
x_sec = get_section(x, self.breaks)
return w[x_sec]