ex)
from tensorflow.keras.optimizers import RMSprop, Nadam
def get_bert_finetuning_model(model):
inputs = model.inputs[:2]
dense = model.layers[-3].output
outputs = keras.layers.Dense(16, activation='sigmoid',
name = 'real_output1')(dense)
outputs = keras.layers.Dense(1, activation='sigmoid',kernel_initializer=keras.initializers.TruncatedNormal(stddev=0.02),
name = 'real_output2')(outputs)
bert_model = keras.models.Model(inputs, outputs)
# bert_model.compile(
# optimizer=RAdam(learning_rate=0.00001, weight_decay=0.0025),
# loss='binary_crossentropy',
# metrics=['accuracy'])
bert_model.compile(loss='binary_crossentropy',
optimizer=Nadam(lr=0.00001, beta_1=0.9, beta_2=0.999, epsilon=None, schedule_decay=0.004),
metrics=['acc'])
return bert_model