PT21-22-Reseau-Neurones/tests/generateSobekFlowerGarden.py

34 lines
628 B
Python
Raw Normal View History

2022-02-17 16:14:21 +01:00
#!/bin/python3
import random
import numpy as np
import math
import pickle
trainPoints = []
trainLabels = []
random.seed(1216513)
2022-03-10 15:09:20 +01:00
for i in range(1000):
2022-02-17 16:14:21 +01:00
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)