Advertisement
teceai

Untitled

May 5th, 2021
2,097
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. from tensorflow import keras
  2. import matplotlib.pyplot as plt
  3. import numpy as np
  4.  
  5.  
  6. features_train = np.load('/datasets/fashion_mnist/train_features.npy')
  7. target_train = np.load('/datasets/fashion_mnist/train_target.npy')
  8. features_test = np.load('/datasets/fashion_mnist/test_features.npy')
  9. target_test = np.load('/datasets/fashion_mnist/test_target.npy')
  10.  
  11. features_train = features_train.reshape(features_train.shape[0], 28 * 28)
  12. features_test = features_test.reshape(features_test.shape[0], 28 * 28)
  13.  
  14. print("Обучающая:", features_train.shape)
  15. print("Тестовая:", features_test.shape)
  16.  
  17. model = keras.models.Sequential()
  18. model.add(keras.layers.Dense(units = 1, input_dim = features_train.shape[1], activation = 'softmax'))
  19. model.compile(loss='sparse_categorical_crossentropy', optimizer = 'sgd')
  20. model.fit(features_train, target_train, epochs=1, verbose=2,
  21.                     validation_data=(features_test, target_test))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement