| import numpy as np | import numpy as np | ||||
| import optuna | import optuna | ||||
| densite = 10 | |||||
| densite = 100 | |||||
| start1 = 5 | |||||
| stop1 = 15 | |||||
| start2 = 35 | |||||
| stop2 = 45 | |||||
| start1 = 15 | |||||
| stop1 = 35 | |||||
| start2 = 55 | |||||
| stop2 = 75 | |||||
| start = -50 | |||||
| stop = 150 | |||||
| start = 0 | |||||
| stop = 100 | |||||
| training = [np.concatenate((np.linspace(start1, stop1, (stop1-start1)*densite), | training = [np.concatenate((np.linspace(start1, stop1, (stop1-start1)*densite), | ||||
| np.linspace(start2, stop2, (stop2-start2)*densite)))] | np.linspace(start2, stop2, (stop2-start2)*densite)))] | ||||
| def objectif(trial) : | def objectif(trial) : | ||||
| HIDDEN = trial.suggest_int('hidden',64,512) | |||||
| SIZE = trial.suggest_int('size',0,2) | |||||
| HIDDEN = trial.suggest_int('hidden',32,128) | |||||
| SIZE = trial.suggest_int('size',0,4) | |||||
| DROPOUT = trial.suggest_float('dropout', 0,0.3) | DROPOUT = trial.suggest_float('dropout', 0,0.3) | ||||
| model = tf.keras.Sequential() | model = tf.keras.Sequential() | ||||
| model.add(tf.keras.layers.Dense(HIDDEN, input_shape=(1,), activation=tfa.activations.snake)) | model.add(tf.keras.layers.Dense(HIDDEN, input_shape=(1,), activation=tfa.activations.snake)) | ||||
| metrics=['mse']) | metrics=['mse']) | ||||
| history = model.fit(x=training[0], y=training[1], batch_size=4, | history = model.fit(x=training[0], y=training[1], batch_size=4, | ||||
| epochs=3000, shuffle=True, | |||||
| epochs=100, shuffle=True, | |||||
| #validation_data=(validation[0], validation[1]), | #validation_data=(validation[0], validation[1]), | ||||
| verbose='auto') | verbose='auto') | ||||