application_vnd.jupyter.stderr_output_2.png text_plain_output_3.png text_plain_output_1.png
import numpy as np

import numpy as np

import tensorflow as tf

import tensorflow as tf

import tensorflow as tf

import tensorflow as tf

def solution_model():
    xs = np.array([-1.0, 0.0, 1.0, 2.0, 3.0, 4.0], dtype=float)
    ys = np.array([5.0, 6.0, 7.0, 8.0, 9.0, 10.0], dtype=float)
    model = tf.keras.Sequential([tf.keras.layers.Dense(1, input_shape=[1])])
    model.compile(loss='mean_squared_error', optimizer='sgd')
    model.fit(xs, ys, epochs=1000)
    return model

if __name__ == '__main__':
    model = solution_model()
    model.save('mymodel.h5')

def solution_model():
    fashion_mnist = tf.keras.datasets.fashion_mnist
    (training_images, training_labels), (val_images, val_label) = fashion_mnist.load_data()
    training_images = training_images / 255.0
    val_images = val_images / 255.0
    training_images = np.expand_dims(training_images, axis=3)
    val_images = np.expand_dims(val_images, axis=3)
    model = tf.keras.Sequential([tf.keras.layers.Conv2D(14, (3, 3), activation='relu', input_shape=(28, 28, 1)), tf.keras.layers.MaxPooling2D(2, 2), tf.keras.layers.Flatten(), tf.keras.layers.Dense(128, activation='relu'), tf.keras.layers.Dense(10, activation='softmax')])
    model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['acc'])
    model.fit(training_images, training_labels, validation_data=(val_images, val_label), epochs=5)
    return model

if __name__ == '__main__':
    model = solution_model()
    model.save('mymodel.h5')