from keras.layers import BatchNormalization
import keras_tuner
from tensorflow import keras
def build_model(hp):
ip = Input(shape=(X.shape[1],))
n = BatchNormalization()(ip)
n = Dense(hp.Choice('units', [8, 16, 32, 64, 128, 256]),
activation='elu')(n)
n = Dropout(0.5)(n)
n = BatchNormalization()(n)
n = Dense(hp.Choice('units', [8, 16, 32, 64, 128, 256]),
activation='elu')(n)
n = BatchNormalization()(n)
n = Dense(hp.Choice('units', [8, 16, 32, 64, 128, 256]),
activation='elu')(n)
n = Dropout(0.5)(n)
n = BatchNormalization()(n)
n = Dense(hp.Choice('units', [8, 16, 32, 64, 128, 256]),
activation='elu')(n)
n = Dense(1, activation='sigmoid')(n)
model = Model(inputs=ip, outputs=n)
model.compile(loss='mse', optimizer='adam', metrics='accuracy')
return model
tuner3 = keras_tuner.RandomSearch(
build_model, objective='val_accuracy', max_trials=5, directory='./tuner4')
tuner3.search(X, y, epochs=1500, validation_split=0.1)
best_model3 = tuner3.get_best_models()[0]
best_model3.evaluate(X_test, y_test)
'DeepLearning' 카테고리의 다른 글
Deeplearning - 컨볼루션 신경망 개념 (1) | 2022.11.01 |
---|---|
DeepLearning - keras.initializers 예제 (0) | 2022.11.01 |
DeepLearning - 컨볼루션 신경망 다중 클래스 분류 (0) | 2022.10.31 |
DeepLearning - keras initializer 종류 (0) | 2022.10.31 |
DeepLearning - tensorflow Xavier Initialization (0) | 2022.10.31 |