Skip to content

Commit b41fbbf

Browse files
committed
training and testing bounds different
1 parent d524958 commit b41fbbf

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

Summer20/NeuralNetwork/tflinear.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ def coolLinear(x):
5050
# plt.legend(loc='lower right')
5151
# plt.show()
5252

53+
bounds = (-15,15) # represents full system dynamics
54+
5355
# generate test data
5456
inputTest, outputTest = randomPoints(10, bounds, boolfunc)
5557
print(model.predict(np.array(inputTest)))
@@ -63,7 +65,7 @@ def coolLinear(x):
6365
y = boolfunc(x)
6466

6567
plt.plot(x,y, label= 'y = 1', markersize = 2, c='c')
66-
ax.scatter(inputTest, outputTest, label = 'training', c='b')
68+
ax.scatter(inputList, outputList, label = 'training', c='b')
6769
ax.scatter(inputTest,model.predict(np.array(inputTest)), label = 'testing', c='r')
6870
plt.legend(loc='lower right')
6971
plt.show()

Summer20/NeuralNetwork/tfquad.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,21 @@ def generatePoints(number, bounds):
4242
# plt.legend(loc='lower right')
4343
# plt.show()
4444

45+
bounds = (-15,15)
4546
# generate test data
46-
inputTest, outputTest = generatePoints(10, bounds)
47+
inputTest, outputTest = generatePoints(20, bounds)
4748
print(model.predict(np.array(inputTest)))
4849
print(outputTest)
4950

5051
# graph of the test, train points
5152
graph = plt.figure()
5253
ax = graph.add_subplot(111)
5354

54-
x = np.linspace(-10,10,500)
55+
x = np.linspace(-15,15,500)
5556
y = x**2
5657

5758
plt.plot(x,y, label= 'y = x^2', markersize = 2, c='c')
58-
ax.scatter(inputTest, outputTest, label = 'training', c='b')
59+
ax.scatter(inputList, outputList, label = 'training', c='b')
5960
ax.scatter(inputTest,model.predict(np.array(inputTest)), label = 'testing', c='r')
6061
plt.legend(loc='lower right')
6162
plt.show()

Summer20/NeuralNetwork/tfsin.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

4343
angleList, 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
5050
model = models.Sequential()
51-
model.add(layers.Dense(12, activation='tanh', input_shape=(1,)))
51+
model.add(layers.Dense(16, activation='tanh', input_shape=(1,)))
5252
model.add(layers.Dense(1, activation=None))
5353
model.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))
7070
print(model.predict(np.array(angleTest)))
7171
print(sinTest)
7272

@@ -75,7 +75,7 @@ def selectPoints(number, angle=90):
7575
graph = plt.figure()
7676
ax = 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)
7979
y = np.sin(x)
8080

8181
plt.plot(x,y, label= 'y = sin(x)', markersize = 2, c='c')

0 commit comments

Comments
 (0)