TensorFlow 基础
import tensorflow as tf # 创建模型 model = tf.keras.Sequential([ tf.keras.layers.Dense(128, activation='relu'), tf.keras.layers.Dropout(0.2), tf.keras.layers.Dense(10, activation='softmax') ]) # 编译模型 model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])
训练模型
# 训练 model.fit(X_train, y_train, epochs=10, validation_split=0.2) # 评估 test_loss, test_acc = model.evaluate(X_test, y_test)
转载请注明:周志洋的博客 » Python机器学习-深度学习入门