SHARE
TWEET

Untitled

a guest Jul 21st, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from __future__ import absolute_import, division, print_function, unicode_literals
  2.  
  3. # TensorFlow and tf.keras
  4. import tensorflow as tf
  5. from tensorflow import keras
  6.  
  7. # Helper libraries
  8. import numpy as np
  9. import matplotlib.pyplot as plt
  10.  
  11. print(tf.__version__)
  12. import tensorflowjs
  13.  
  14. fashion_mnist = keras.datasets.fashion_mnist
  15.  
  16. (train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()
  17.  
  18. model = keras.Sequential([
  19.     keras.layers.Flatten(input_shape=(28, 28)),
  20.     keras.layers.Dense(128, activation=tf.nn.relu),
  21.     keras.layers.Dense(10, activation=tf.nn.softmax)
  22. ])
  23.  
  24. model.compile(optimizer='adam',
  25.               loss='sparse_categorical_crossentropy',
  26.               metrics=['accuracy'])
  27.  
  28. train_images = train_images / 255.0
  29.  
  30. test_images = test_images / 255.0
  31.  
  32.  
  33. model.summary()
  34. model.fit(train_images, train_labels, epochs=5)
  35.  
  36. tensorflowjs.converters.save_keras_model(model, './my_keras_model')
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top