@@ -37,7 +37,7 @@ def selectPoints(number, angle=90):
3737
3838
3939# generate training data
40- angles = (- 360 , 360 ) # represents full system dynamics
40+ angles = (- 720 , 720 ) # represents full system dynamics
4141#angles = (0,90) # doesn't represent full system dynamics
4242
4343angleList , sinList = randomPoints (10000 , angles ) # good number of points and random points
@@ -48,7 +48,7 @@ def selectPoints(number, angle=90):
4848
4949# neural network code
5050model = models .Sequential ()
51- model .add (layers .Dense (12 , activation = 'tanh' , input_shape = (1 ,)))
51+ model .add (layers .Dense (16 , activation = 'tanh' , input_shape = (1 ,)))
5252model .add (layers .Dense (1 , activation = None ))
5353model .compile (optimizer = 'Adam' ,
5454 loss = losses .MeanSquaredError (),
@@ -66,7 +66,7 @@ def selectPoints(number, angle=90):
6666# plt.show()
6767
6868# generate test data
69- angleTest , sinTest = randomPoints (10 )
69+ angleTest , sinTest = randomPoints (20 , ( - 1080 , 1080 ) )
7070print (model .predict (np .array (angleTest )))
7171print (sinTest )
7272
@@ -75,7 +75,7 @@ def selectPoints(number, angle=90):
7575graph = plt .figure ()
7676ax = graph .add_subplot (111 )
7777
78- x = np .linspace (- math .pi * 2 ,math .pi * 2 ,300 )
78+ x = np .linspace (- math .pi * 6 ,math .pi * 6 ,300 )
7979y = np .sin (x )
8080
8181plt .plot (x ,y , label = 'y = sin(x)' , markersize = 2 , c = 'c' )
0 commit comments