Random Walk¤
RandomWalk
¤
Bases: Model
Source code in blackbirds/models/random_walk.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
|
__init__(n_timesteps, tau_softmax=0.1)
¤
Implements a differentiable random walk.
\[
X_t = \sum_{i=1}^t (2\eta - 1),
\]
where
\[
\eta \sim \text{Bernoulli}(p).
\]
Arguments:
n_timesteps
(int): Number of timesteps to simulate.tau_softmax
(float): Temperature parameter for the Gumbel-Softmax
Source code in blackbirds/models/random_walk.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
|
step(params, x)
¤
Simulates a random walk step using the Gumbel-Softmax trick.
Arguments:
params
: a tensor of shape (1,) containing the logit probability of moving forward at each timestep.x
: a tensor of shape (n,) containing the time-series of positions.
Danger
probability is given in logit, so the input is transformed using the sigmoid function.
Source code in blackbirds/models/random_walk.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|