manim_ml.neural_network package#

Subpackages#

Submodules#

manim_ml.neural_network.neural_network module#

Neural Network Manim Visualization

This module is responsible for generating a neural network visualization with manim, specifically a fully connected neural network diagram.

Example

# Specify how many nodes are in each node layer layer_node_count = [5, 3, 5] # Create the object with default style settings NeuralNetwork(layer_node_count)

class manim_ml.neural_network.neural_network.FeedForwardNeuralNetwork(layer_node_count, node_radius=0.08, node_color='#58C4DD', **kwargs)#

Bases: manim_ml.neural_network.neural_network.NeuralNetwork

NeuralNetwork with just feed forward layers

animation_overrides = {<class 'manim.animation.creation.Create'>: <function NeuralNetwork._create_override>}#
class manim_ml.neural_network.neural_network.NeuralNetwork(input_layers, edge_color='#FFFFFF', layer_spacing=0.2, animation_dot_color='#FC6255', edge_width=2.5, dot_radius=0.03, title=' ')#

Bases: manim.mobject.mobject.Group

animation_overrides = {<class 'manim.animation.creation.Create'>: <function NeuralNetwork._create_override>}#
insert_layer(layer, insert_index)#

Inserts a layer at the given index

make_forward_pass_animation(run_time=10, passing_flash=True, layer_args={}, **kwargs)#

Generates an animation for feed forward propagation

remove_layer(layer)#

Removes layer object if it exists

replace_layer(old_layer, new_layer)#

Replaces given layer object

set_z_index(z_index_value: float, family=False)#

Overriden set_z_index

manim_ml.neural_network.neural_network_transformations module#

Transformations for manipulating a neural network object.

class manim_ml.neural_network.neural_network_transformations.InsertLayer(mobject=None, *args, use_override=True, **kwargs)#

Bases: manim.animation.composition.AnimationGroup

Animation for inserting layer at given index

get_connective_layer_widths()#

Gets the widths of the connective layers

make_create_connective_layers_animation(before_connective, after_connective)#

Create connective layers

make_create_layer_animation()#

Animates the creation of the layer

make_move_layers_animation()#

Shifts layers before and after

remove_connective_layer_animation()#

Removes the connective layer before the insertion index

class manim_ml.neural_network.neural_network_transformations.RemoveLayer(mobject=None, *args, use_override=True, **kwargs)#

Bases: manim.animation.composition.AnimationGroup

Animation for removing a layer from a neural network.

Note: I needed to do something strange for creating the new connective layer. The issue with creating it intially is that the positions of the sides of the connective layer depend upon the location of the moved layers after the move animations are performed. However, all of these animations are performed after the animations have been created. This means that the animation depends upon the state of the neural network layers after previous animations have been run. To fix this issue I needed to use an UpdateFromFunc.

get_connective_layers()#

Gets the connective layers before and after self.layer

make_move_animation()#

Collapses layers

make_new_connective_animation()#

Makes new connective layer

make_remove_animation()#

Removes layer and the surrounding connective layers

make_remove_connective_layers_animation()#

Removes the connective layers before and after layer if they exist

make_remove_layer_animation()#

Removes the layer

manim_ml.neural_network.variational_autoencoder module#

Variational Autoencoder Manim Visualizations

In this module I define Manim visualizations for Variational Autoencoders and Traditional Autoencoders.

class manim_ml.neural_network.variational_autoencoder.VariationalAutoencoder(encoder_nodes_per_layer=[5, 3], decoder_nodes_per_layer=[3, 5], point_color='#58C4DD', dot_radius=0.05, ellipse_stroke_width=1.0, layer_spacing=0.5)#

Bases: manim.mobject.types.vectorized_mobject.VGroup

Variational Autoencoder Manim Visualization

animation_overrides = {<class 'manim.animation.creation.Create'>: <function VariationalAutoencoder._create_vae>}#
make_image_forward_pass(input_image, output_image, run_time=1.5)#

Override forward pass animation specific to a VAE

make_triplet_forward_pass(triplet)#

Module contents#