Skip to content

Latest commit

 

History

History
87 lines (71 loc) · 2.99 KB

neuron-pov.md

File metadata and controls

87 lines (71 loc) · 2.99 KB

Neuron POV

Animation: https://x.com/0interestrates/status/1766269387248734673?s=20

Prompt:

imagine the point of view of a neuron in a really large neural net. think about what the neuron sees and feels? write manim code to animate what is seen and felt from the point of view of a neuron

Generated code:

from manim import *

class NeuronPOV(Scene):
    def construct(self):
        # Create a neuron
        neuron = Circle(radius=0.5, color=BLUE)
        neuron_text = Text("Neuron", font_size=24).next_to(neuron, DOWN)
        self.play(Create(neuron), Write(neuron_text))
        self.wait(1)

        # Incoming signals
        num_signals = 10
        signals = VGroup(*[
            Line(start=np.array([-7, (i-num_signals/2)*0.5, 0]), 
                 end=neuron.get_center(),
                 stroke_color=YELLOW, 
                 stroke_width=2)
            for i in range(num_signals)
        ])
        
        self.play(Create(signals), run_time=2)
        self.wait(1)
        
        # Neuron processes signals
        self.play(neuron.animate.set_fill(BLUE, opacity=0.5))
        self.play(Flash(neuron, color=WHITE, line_length=0.3, num_lines=12))
        self.wait(0.5)
        
        # Neuron fires output
        output_signal = Line(start=neuron.get_center(), 
                             end=np.array([7, 0, 0]),
                             stroke_color=RED,
                             stroke_width=4)
        self.play(Create(output_signal))
        self.wait(1)
        
        # Signals continue to flow
        for _ in range(3):
            self.play(
                Flash(neuron, color=WHITE, line_length=0.3, num_lines=12),
                *[signal.animate.set_stroke(color=YELLOW, width=2) for signal in signals],
                output_signal.animate.set_stroke(color=RED, width=4),
                run_time=1
            )
            self.wait(0.5)
        
        # Neuron resets
        self.play(
            neuron.animate.set_fill(BLUE, opacity=1),
            FadeOut(output_signal),
            *[signal.animate.set_stroke(color=YELLOW, width=2) for signal in signals]
        )
        self.wait(1)

        # Thinking bubble to represent neuron's limited perspective
        thought_bubble = ThoughtBubble(direction=RIGHT, height=2, width=3)
        thought_bubble.next_to(neuron, UL)
        thought_bubble.shift(RIGHT)
        
        self.play(Create(thought_bubble))
        self.wait(1)

        thought_text = MarkupText("I receive signals,<br>process them,<br>and send output...<br>but I don't know<br>the big picture!", font_size=24)
        thought_text.move_to(thought_bubble.get_bubble_center())
        self.play(Write(thought_text), run_time=2)
        self.wait(2)
        
        self.play(
            FadeOut(thought_bubble),
            FadeOut(thought_text),
            FadeOut(signals),
            FadeOut(neuron),
            FadeOut(neuron_text)
        )

Note: depending on your manim version, ThoughtBubble and <br> tag in MarkupText may not work