debut fleures
This commit is contained in:
parent
58d2d70f2b
commit
dcddbd017f
BIN
tests/flowerGardenData
Executable file
BIN
tests/flowerGardenData
Executable file
Binary file not shown.
17
tests/flowerGardenLearningVisualization.py
Executable file
17
tests/flowerGardenLearningVisualization.py
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/python3
|
||||||
|
from sys import path
|
||||||
|
path.insert(1, "..")
|
||||||
|
from sobek.network import network
|
||||||
|
import pickle
|
||||||
|
|
||||||
|
with open("flowerGardenData", "rb") as file:
|
||||||
|
data = pickle.load(file)
|
||||||
|
|
||||||
|
trainPoints = data[0]
|
||||||
|
trainLabels = data[1]
|
||||||
|
|
||||||
|
myNetwork = network(2, 16, 1)
|
||||||
|
|
||||||
|
learningRate = 5.0
|
||||||
|
|
||||||
|
myNetwork.train(trainPoints, trainLabels, learningRate, batchSize=10, epochs=1000, visualize=True)
|
34
tests/generateSobekFlowerGarden.py
Executable file
34
tests/generateSobekFlowerGarden.py
Executable file
@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/python3
|
||||||
|
import random
|
||||||
|
import numpy as np
|
||||||
|
import math
|
||||||
|
import pickle
|
||||||
|
|
||||||
|
trainPoints = []
|
||||||
|
trainLabels = []
|
||||||
|
|
||||||
|
random.seed(1216513)
|
||||||
|
|
||||||
|
for i in range(100):
|
||||||
|
x = random.randint(-50, 50)
|
||||||
|
y = random.randint(-50, 50)
|
||||||
|
|
||||||
|
distance = math.sqrt(x**2 + y**2)
|
||||||
|
|
||||||
|
if (distance < 10 or 20 < distance < 30):
|
||||||
|
trainLabels.append(np.ones(1))
|
||||||
|
else :
|
||||||
|
trainLabels.append(np.zeros(1))
|
||||||
|
|
||||||
|
x = (x+50)/100
|
||||||
|
y = (y+50)/100
|
||||||
|
|
||||||
|
trainPoints.append(np.array([x, y]))
|
||||||
|
|
||||||
|
print(trainPoints[1])
|
||||||
|
print(trainLabels[1])
|
||||||
|
|
||||||
|
data = [trainPoints, trainLabels]
|
||||||
|
|
||||||
|
with open("flowerGardenData", "wb") as file:
|
||||||
|
pickle.dump(data, file)
|
Loading…
Reference in New Issue
Block a user