Open helblazer811 opened 1 year ago
Here is some code I wrote for a generic model training class in manim:
`from manim import *
class ModelTraining(Scene): def construct(self): model_title = TextMobject("Model Training") self.play(Write(model_title)) self.wait()
training_data = TextMobject("Training Data")
self.play(Write(training_data))
self.wait()
model_training = TextMobject("Training the Model")
self.play(Write(model_training))
self.wait()
accuracy = TextMobject("Accuracy:")
accuracy_value = TextMobject("100%")
accuracy_group = VGroup(accuracy, accuracy_value)
accuracy_group.arrange(RIGHT)
accuracy_group.to_edge(UP)
self.play(Write(accuracy_group))
self.wait()
testing_data = TextMobject("Testing Data")
self.play(Write(testing_data))
self.wait()
model_testing = TextMobject("Testing the Model")
self.play(Write(model_testing))
self.wait()
test_accuracy = TextMobject("Test Accuracy:")
test_accuracy_value = TextMobject("99%")
test_accuracy_group = VGroup(test_accuracy, test_accuracy_value)
test_accuracy_group.arrange(RIGHT)
test_accuracy_group.to_edge(UP)
self.play(Write(test_accuracy_group))
self.wait()
`
Here is an example of a simple transformer model implemented which inherits from this class: `from manim import * class TransformerModelScene(ModelTrainingScene): def init(self, kwargs): ModelTrainingScene.init(self, kwargs) def setup(self): self.prepare_data() self.add_data_points() self.add_transformer_model() def prepare_data(self):
pass
def add_transformer_model(self):
# Add the Transformer model to the scene
pass
class TransformerModelTraining(Scene): def construct(self): self.add(TransformerModelScene())
` In this example, TransformerModelScene is a subclass of ModelTrainingScene and inherits all of its methods and attributes. The setup method is overridden to prepare the data for the Transformer model and add the model to the scene.
In the TransformerModelScene class, the prepare_data and add_transformer_model methods need to be implemented to prepare the data for the Transformer model and add the model to the scene, respectively.
Finally, TransformerModelTraining is a scene that adds the TransformerModelScene to the animation.
Interesting ideas! I'm especially excited by the idea of creating more animations like ForwardPass with similar syntax to how the animations are done in the core library.
Manim has the ability to represent animations as classes. These classes can take parameters and they can wrap around a passed Mobject (in our case this could be a neural network) and then a mobject specific animation is run. You can override such animations like Create (see neural_network.py). It would be interesting to make a generic TrainModel animation that is implemented by various models and emulates the training procedure.
For now, I could implement these animations as functions in the
manim_ml/neural_network/animations
directory.