a20200510_12.py
from manimlib.imports import *
import numpy as npclass a20200510_12(GraphScene):
CONFIG = {
"y_min" : 0,
"y_max" : 10,
"x_min" : -3,
"x_max" : 7,
"y_axis_label": "$y$",
}def construct(self):
self.setup_axes(animate=True,)g = lambda x : (x-1)**2 + 2graph_g = self.get_graph(g)
self.play(ShowCreation(graph_g))formula = TexMobject("")
formula.to_edge(RIGHT, buff = 1)
self.add(formula)for w in range(-3,3):
for b in range(-5,3):formula_1 = "\\max ( {} x + {}, 0 ) ".format(w,b)
formula_1 = TexMobject(formula_1)
formula_1.to_edge(RIGHT, buff = 1)
f = lambda x : max(w*x + b, 0)
graph_f = self.get_graph(f)
self.play(
ShowCreation(graph_f),
Transform(formula, formula_1))
a20200514_20.py
from manimlib.imports import *class a20200514_20(Scene):
def construct(self):
#1
string = r"""
\Big( 1 + {1 \over n}\Big)^n
""".split()
f_1 = TexMobject(*string)
#f_1.to_edge(UL, buff=0.5)string = r"""
\Big( 1 + {1 \over n}\Big)^2 = 1 + 2 \Big( {1 \over n} \Big) + \Big( {1 \over n} \Big)^2
""".split()
f_2 = TexMobject(*string)string = r"""
\Big( 1 + {1 \over n}\Big)^3
= 1 + 3 \Big( {1 \over n} \Big) + 3 \Big( {1 \over n} \Big)^2 + \Big( {1 \over n} \Big)^3
""".split()
f_3 = TexMobject(*string)string = r"""
\vdots
""".split()
f_4 = TexMobject(*string)string = r"""
\Big( 1 + {1 \over n}\Big)^n
= 1 + {n \choose 1} \Big( {1 \over n} \Big) + \cdots
+ {n \choose j} \Big( {1 \over n} \Big)^j + \cdots
+ \Big( {1 \over n} \Big)^n
""".split()
f_5 = TexMobject(*string)F = VGroup(f_1, f_2, f_3, f_4, f_5)
F.arrange_submobjects(DOWN, buff=0.5)
self.play(Write(F[:]))
self.wait()
self.play(FadeOut(F))
a20200517_14.py
from manimlib.imports import *class a20200517_14(Scene):
def construct(self):t_x = TexMobject(r"""
\texttt{x = [6,7,8,9]}
""")
t_y = TexMobject(r"""
\texttt{y = [10,20,30,40]}
""")t = VGroup(t_x, t_y).arrange_submobjects(DOWN, buff=0.5)
self.play(ShowCreation(t))
self.wait()
code_x = TexMobject(r"""
\texttt{x = [6,7,8,9]}
""")
code_y = TexMobject(r"""
\texttt{y = [10,20,30,40]}
""")
#code_xy_g.scale(0.7).next_to(t_1, DOWN, aligned_edge=LEFT, buff=0)#code_xy_g[0][3].set_color(YELLOW)code_xy_g = VGroup(code_x,code_y).arrange_submobjects(DOWN,aligned_edge=LEFT,buff=0).scale(0.7).move_to([-5,2,0])
self.play(ReplacementTransform(t, code_xy_g))layer_1_code = TexMobject(r"""
\texttt{Dense(1, input\textunderscore shape=[1])}
""")
layer_1_code.scale(0.7).next_to(code_xy_g, DOWN, aligned_edge=LEFT, buff=0.2)
self.play(ShowCreation(layer_1_code))c = Circle(radius=0.1)
c.move_to([2,0,0])self.play(ReplacementTransform(layer_1_code.copy(),c))
self.wait()
###t_3 = TexMobject(r"""
\texttt{6}
""")
t_3.move_to([2,3,0]).scale(0.7)t_4 = TexMobject(r"""
\texttt{10}
""")
t_4.move_to([2,-3,0]).scale(0.7)self.play(ReplacementTransform(t_x[0][3].copy(), t_3))
self.play(ReplacementTransform(t_y[0][3:5].copy(), t_4))###layer_1_f = TexMobject(r"""
w\cdot[\quad] + b
""")layer_1_f.move_to([2,0,0])self.play(ReplacementTransform(c, layer_1_f))
self.wait()###
self.play(Uncreate(layer_1_code))
self.play(FadeOut(layer_1_f))
self.wait()layer_1_code = TexMobject(r"""
\texttt{Dense(2, input\textunderscore shape=[1])}
""")
layer_1_code.scale(0.7).next_to(code_xy_g, DOWN, aligned_edge=LEFT, buff=0.2)
self.play(Write(layer_1_code))c_2 = Circle(radius=0.1)
c_3 = Circle(radius=0.1)
c_g = VGroup(c_2,c_3)
c_g.arrange_submobjects(RIGHT, buff=1)
c_g.move_to([2,0,0])self.play(ReplacementTransform(layer_1_code.copy(),c_g))
self.wait()###f_2 = TexMobject(r"""
w_{1}\cdot[\quad] + b_{1}
""")
f_3 = TexMobject(r"""
w_{2}\cdot[\quad] + b_{2}
""")f_g = VGroup(f_2,f_3).arrange_submobjects(RIGHT, buff=1,).scale(0.7).move_to([2,0,0])self.play(ReplacementTransform(c_g,f_g))
self.wait()###
layer_2_code = TexMobject(r"""
\texttt{Dense(1)}
""")
layer_2_code.scale(0.7).next_to(layer_1_code,DOWN,aligned_edge=LEFT,buff=0)self.play(Write(layer_2_code))
self.wait()self.play(FadeOut(f_g))
self.wait()c_4 = Circle(radius=0.1)
c_5 = Circle(radius=0.1)
c_6 = Circle(radius=0.1)
c = VGroup(c_4,c_5).arrange_submobjects(RIGHT, buff=1,)
c = VGroup(c,c_6).arrange_submobjects(DOWN, buff=1).move_to([2,0,0])self.play(ReplacementTransform(layer_2_code.copy(), c))
self.wait()layer_2_f_1 = TexMobject(r"""
w_{11}\cdot[\quad] + b_{11}
""")
layer_2_f_2 = TexMobject(r"""
w_{12}\cdot[\quad] + b_{12}
""")
layer_2_f_3 = TexMobject(r"""
w_{21}\cdot[\quad] + w_{21}\cdot[\quad] + b_{21}
""")layer_2_g = VGroup(layer_2_f_1, layer_2_f_2).arrange_submobjects(RIGHT, buff=1)
layer_2_g = VGroup(layer_2_g, layer_2_f_3).arrange_submobjects(DOWN,buff=1).scale(0.7).move_to([2,0,0])self.play(ReplacementTransform(c,layer_2_g))
self.wait()
a20200522_04.py
from manimlib.imports import *class a20200522_04(Scene):
def construct(self):title_1 = TextMobject("The simplest case")
title_1.to_edge(UP, buff=1)
self.play(Write(title_1))
self.wait()x_equal = TexMobject("x = ")
x_mat = Matrix([5,6,"\\vdots",8], element_alignment_corner=DOWN)
obj_1 = VGroup(x_equal,x_mat).arrange_submobjects()y_equal = TexMobject("y = ")
obj_1 = VGroup(obj_1,y_equal).arrange_submobjects(buff=1)y_mat = Matrix([21,31,"\\vdots",63], element_alignment_corner=DOWN)
obj_1 = VGroup(obj_1,y_mat).arrange_submobjects()self.play(ShowCreation(obj_1))
self.wait()###title_2 = TextMobject("More Features")
title_2.to_edge(UP, buff=1)
self.play(ReplacementTransform(title_1, title_2))
self.wait()x_equal = TexMobject("x = ")
x_mat = Matrix( [ [5,2], [4,6], "\\vdots", [8,8] ], element_alignment_corner=DOWN )
obj_2 = VGroup(x_equal,x_mat).arrange_submobjects()y_equal = TexMobject("y = ")
obj_2 = VGroup(obj_2,y_equal).arrange_submobjects(buff=1)y_mat = Matrix([21,31,"\\vdots",63], element_alignment_corner=DOWN)
obj_2 = VGroup(obj_2,y_mat).arrange_submobjects()self.play(ReplacementTransform(obj_1, obj_2))
self.wait()#title_3 = TextMobject("Or classification")
title_3.to_edge(UP, buff=1)
self.play(ReplacementTransform(title_2, title_3))
self.wait()x_equal = TexMobject("x = ")
x_mat = Matrix( [ [5,2], [4,6], "\\vdots", [8,8] ], element_alignment_corner=DOWN )
obj_3 = VGroup(x_equal,x_mat).arrange_submobjects()y_equal = TexMobject("y = ")
obj_3 = VGroup(obj_3,y_equal).arrange_submobjects(buff=1)y_mat = Matrix(['cat','dog',"\\vdots",'dog'], element_alignment_corner=DOWN)
obj_3 = VGroup(obj_3,y_mat).arrange_submobjects()equal_sign = TexMobject("=")
obj_3 = VGroup(obj_3,equal_sign).arrange_submobjects()y_mat_2 = Matrix([[1,0],[0,1],"\\vdots",[0,1]], element_alignment_corner=DOWN)
obj_3 = VGroup(obj_3,y_mat_2).arrange_submobjects()self.play(ReplacementTransform(obj_2, obj_3))
self.wait()
next