from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense # Define the model architecture model = Sequential([ Dense(64, activation='relu', input_shape=(10,)), Dense(1, activation='sigmoid') ]) # Compile the model model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])
from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense # Define the model architecture model = Sequential([ Dense(64, activation='relu', input_shape=(10,)), Dense(32, activation='relu'), Dense(3, activation='softmax') ]) # Compile the model model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy', 'precision', 'recall'])As you can see, the Model.compile() method allows for a high degree of flexibility in configuring the model for training. This functionality is part of the Keras library, which is included with TensorFlow as a sub-package.