This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #%% IMPORTS | |
| import torch | |
| import pytorch_lightning as pl | |
| import matplotlib.pyplot as plt | |
| from pytorch_lightning import Trainer | |
| from torch.nn import functional as F | |
| import pyro | |
| import pyro.distributions as dist | |
| # %% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| def cellular_automaton(rule_number, size, steps, | |
| init_cond='random', impulse_pos='center'): | |
| """Generate the state of an elementary cellular automaton after a pre-determined | |
| number of steps starting from some random state. | |
| Args: | |
| rule_number (int): the number of the update rule to use | |
| size (int): number of cells in the row |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| powers_of_two = np.array([[4], [2], [1]]) # shape (3, 1) | |
| def step(x, rule_binary): | |
| """Makes one step in the cellular automaton. | |
| Args: | |
| x (np.array): current state of the automaton | |
| rule_binary (np.array): the update rule |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| import matplotlib.animation as animation | |
| x_start, y_start = -2, -2 # an interesting region starts here | |
| width, height = 4, 4 # for 4 units up and right | |
| density_per_unit = 200 # how many pixles per unit | |
| # real and imaginary axis | |
| re = np.linspace(x_start, x_start + width, width * density_per_unit ) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.