tensorflow 模型的保存与加载
代码
"""
Created on 2020/11/20 9:41
@Author: CY
@email: 5844104706@qq.com
"""
import os
import tensorflow as tf
from tensorflow import keras
print(tf.version.VERSION)
print("# 1 数据集")
(train_images, train_labels), (test_images, test_labels) = tf.keras.datasets.mnist.load_data()
train_labels = train_labels[:1000]
test_labels = test_labels[:1000]
train_images = train_images[:1000].reshape(-1, 28 * 28) / 255.0
test_images = test_images[:1000].reshape(-1, 28 * 28) / 255.0
print("# 2 模型")
def create_model():
model = tf.keras.models.Sequential([
keras.layers.Dense(512, activation='relu', input_shape=(784,)),
keras.layers.Dropout(0.2),