# -*- coding: utf-8 -*-
"""
Created on Wed Nov 24 17:02:16 2021

@author: virgi
"""

# -*- coding: utf-8 -*-
"""
Created on Wed Nov 24 16:58:44 2021

@author: virgi
"""





import tensorflow as tf
import matplotlib.pyplot as plt
from fonction_activation import *

from Creation_donnee import *
import numpy as np

n=20
#création de la base de donnéé
X,Y=creation_sin(-15,-8,n,1,)
X2,Y2=creation_sin(10,18,n,1,)
X=np.concatenate([X,X2])
Y=np.concatenate([Y,Y2])

n=10000
Xv,Yv=creation_sin(-20,20,n,1)




model_xsin=tf.keras.models.Sequential()

model_xsin.add(tf.keras.Input(shape=(1,)))

model_xsin.add(tf.keras.layers.Dense(64, activation=x_sin))
model_xsin.add(tf.keras.layers.Dense(64, activation=x_sin))
model_xsin.add(tf.keras.layers.Dense(64, activation=x_sin))
model_xsin.add(tf.keras.layers.Dense(64, activation=x_sin))
model_xsin.add(tf.keras.layers.Dense(64, activation=x_sin))


model_xsin.add(tf.keras.layers.Dense(1))

opti=tf.keras.optimizers.Adam()

model_xsin.compile(opti, loss='mse', metrics=['accuracy'])


model_xsin.summary()

model_xsin.fit(X, Y, batch_size=1, epochs=10, shuffle='True',validation_data=(Xv, Yv))




Y_predis_xsin=model_xsin.predict(X)
Y_predis_validation_xsin=model_xsin.predict(Xv)




plt.figure()
plt.plot(X,Y,'x',label='donnée')
plt.plot(Xv,Yv,label="validation")
plt.plot(X,Y_predis_xsin,'o',label='prediction sur les donné avec x+sin comme activation')
plt.plot(Xv,Y_predis_validation_xsin,label='prediction sur la validation avec x+sin comme activation')
plt.legend()
plt.show()


"""
Created on Wed Nov 24 16:53:37 2021

@author: virgi
"""

