1、用tf.keras创建模型
inputs = tf.keras.Input(shape=(1000, 9,), name='input')
input = tf.keras.layers.Flatten(name="flatten")(inputs)
f1 = tf.keras.layers.Dense(512, activation='relu', name='dense_1')(input)
d1 = tf.keras.layers.Dropout(0.2,name='dropout_1')(f1)
f2 = tf.keras.layers.Dense(128, activation='relu', name='dense_2')(d1)
outputs = tf.keras.layers.Dense(3, activation='softmax', name='output')(f2)
model = tf.keras.Model(inputs=inputs, outputs=outputs, name='intrusion')
model.summary()
2、模型训练
model.compile(loss='sparse_categorical_crossentropy',
optimizer=tf.keras.optimizers.Adam(),
metrics=['sparse_categorical_accuracy'])
history = model.fit(x_train, y_train,