so i recently discovered really weird behaviour of my AI model. i wanted to build AI model which would try and guess the implicit functions based on the data i give it to it. for example equation of the flower:
And this is how i wrote it in the numpy array:
K = 0.75
a = 9
def f(x):
return x - 2 - 2*np.floor((x - 1)/2)
def r1(x):
return abs(6 * f(a * K * x / 2 / np.pi)) - a/2
t = np.linspace(0, 17 * math.pi, 1000)
x = np.cos(t) * r1(t)
y = np.sin(t) * r1(t)
points = np.vstack((x, y)).T
After that i tried to experiment a bit and allowed my AI to actually try and guess the shape of this flower! at first try it actually got it write. here it is:
Well i got great example, after that i tried to experiment and checked what would happen if i shuffled the point array and i completely got devasting results!
And i coudn’t explain why order of cartesian coordinates mattered to approximate flower implicit function. can anyone explain it?
here is code for AI
# Define the neural network model
model = Sequential()
model.add(Dense(128, input_dim=2, activation='relu'))
model.add(Dense(64, activation='relu'))
model.add(Dense(2, activation='linear'))
# Compile the model
model.compile(optimizer='adam', loss='mean_squared_error')
# Train the model
model.fit(points, points, epochs=100, batch_size=32)