history = model_B_on_A.fit(X_train_B, y_train_B, epochs=4,
validation_data=(X_valid_B, y_valid_B))for layer in model_B_on_A.layers[:-1]:
layer.trainable =True
optimizer = keras.optimizers.SGD(lr=1e-4)# the default lr is 1e-2
model_B_on_A.compile(loss="binary_crossentropy", optimizer=optimizer,
metrics=["accuracy"])
history = model_B_on_A,fit(X_train_B, y_train_B, epochs=16,
validation_data=(X_valid_B, y_valid_B))