helblazer811 / ManimML

ManimML is a project focused on providing animations and visualizations of common machine learning concepts with the Manim Community Library.
MIT License
2.26k stars 136 forks source link

NN scaling issue with Convolutional3DLayer #4

Open fhnaumann opened 1 year ago

fhnaumann commented 1 year ago

At some point there was code commited changing the behaviour of the net when scaling it. If I use the code in the pip package everything works fine (0.0.11 seems to contain only code prior to the 7th of may). https://user-images.githubusercontent.com/54776552/198372984-f704cceb-8582-4bf9-bc23-c15ebb836b34.mp4

However I'm forking the repo (with the latest commit from august) because I need to change some internal code and noticed this problem.

https://user-images.githubusercontent.com/54776552/198373792-fd672ec7-708e-4ebe-b353-e291c8a591dd.mp4

Maybe someone can pinpoint the exact commit which causes this behaviour?

Code used:

class Test(Scene):
    def construct(self):
        # Make the Layer object
        l1 = Convolutional3DLayer(4, 2, 2)
        l2 = Convolutional3DLayer(5, 1, 1)
        l3 = Convolutional3DLayer(2, 3, 3)
        layers = [l1, l2, l3]
        nn = NeuralNetwork(layers)
        nn.scale(2)
        nn.move_to(ORIGIN)
        # Make Animation
        self.add(nn)
        #self.play(Create(nn))
        forward_propagation_animation = nn.make_forward_pass_animation(run_time=5, passing_flash=True)

        self.play(forward_propagation_animation)
fhnaumann commented 1 year ago

Additional note:

The reason I'm forking the project is because I created custom layers which also have corresponding ConnectiveLayers, but in order to make them work they need to be added to the connective_layers_list in the init file. Perhaps let get_connective_layer in util.py take in an optional list with additional classes? That way one can add layers without modifying the source code.

helblazer811 commented 1 year ago

Hey, sorry I haven't had time to work on this project for a while. I spent some time revamping how the convolutional neural network visualization is done and I think it is much more faithful to the actual algorithm. I will also look into a better solution for allowing the library to be extended (new layers, new animations, etc.) without modifying the code. It is still under development but here is an example of the new CNN visualization.

https://user-images.githubusercontent.com/14181830/210123663-a2814144-75e9-427e-a2dc-013f0870cbeb.mov