форкнуто от main/is_dnn
Вы не можете выбрать более 25 тем
Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
4.5 KiB
4.5 KiB
#пункт 1
import os
'/content/drive/MyDrive/Colab Notebooks')
os.chdir(# импорт модулей
from tensorflow import keras
import matplotlib.pyplot as plt
import numpy as np
import sklearn
#пункт 2
# загрузка датасета
from keras.datasets import mnist
= mnist.load_data()
(X_train, y_train), (X_test, y_test)
#пункт 3
# создание своего разбиения датасета
from sklearn.model_selection import train_test_split
# объединяем в один набор
= np.concatenate((X_train, X_test))
X = np.concatenate((y_train, y_test))
y # разбиваем по вариантам
= train_test_split(X, y,
X_train, X_test, y_train, y_test = 10000,
test_size = 60000,
train_size = 123)
random_state # вывод размерностей
print('Shape of X train:', X_train.shape)
print('Shape of y train:', y_train.shape)
#пункт 4
# вывод изображения 1
0], cmap=plt.get_cmap('gray'))
plt.imshow(X_train[
plt.show()# вывод метки для этого изображения
print(y_train[0])
# вывод изображения 2
1], cmap=plt.get_cmap('gray'))
plt.imshow(X_train[
plt.show()# вывод метки для этого изображения
print(y_train[1])
# вывод изображения 3
2], cmap=plt.get_cmap('gray'))
plt.imshow(X_train[
plt.show()# вывод метки для этого изображения
print(y_train[2])
# вывод изображения 4
3], cmap=plt.get_cmap('gray'))
plt.imshow(X_train[
plt.show()# вывод метки для этого изображения
print(y_train[3])
#пункт 5
# развернем каждое изображение 28*28 в вектор 784
= X_train.shape[1] * X_train.shape[2]
num_pixels = X_train.reshape(X_train.shape[0], num_pixels) / 255
X_train = X_test.reshape(X_test.shape[0], num_pixels) / 255
X_test print('Shape of transformed X train:', X_train.shape)
# переведем метки в one-hot
from keras.utils import np_utils
= np_utils.to_categorical(y_train)
y_train = np_utils.to_categorical(y_test)
y_test print('Shape of transformed y train:', y_train.shape)
= y_train.shape[1]
num_classes
print('Shape of transformed X test:', X_test.shape)
print('Shape of transformed Y test:', y_test.shape)
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
/tmp/ipython-input-1074595868.py in <cell line: 0>()
1 #пункт 1
2 import os
----> 3 os.chdir('/content/drive/MyDrive/Colab Notebooks')
4 # импорт модулей
5 from tensorflow import keras
FileNotFoundError: [Errno 2] No such file or directory: '/content/drive/MyDrive/Colab Notebooks'