《Python深度学习》读书笔记
1. 人工智能、机器学习、深度学习之间的关系2. 人工智能:将通常由人类完成的智力任务自动化。3. 机器学习
·
第一章
1. 人工智能、机器学习、深度学习之间的关系
2. 人工智能:将通常由人类完成的智力任务自动化。
3. 机器学习
第二章
keras实现mnist识别
from keras.datasets import mnist
from keras import models
from keras import layers
from keras.utils import to_categorical
import numpy as np
def load_data():
(train_images, train_labels), (test_images, test_labels) = mnist.load_data()
train_images = train_images.reshape((60000, 28 * 28))
train_images = train_images.astype(np.float32) / 255
test_images = test_images.reshape((10000, 28 * 28))
test_images = test_images.astype(np.float32) / 255
train_labels = to_categorical(train_labels)
test_labels = to_categorical(test_labels)
return (train_images, train_labels), (test_images, test_labels)
(x_train, y_train), (x_test, y_test) = load_data()
network = models.Sequential()
network.add(layers.Dense(units=512, activation='relu', input_shape=(28 * 28,)))
network.add(layers.Dense(units=10, activation='softmax'))
network.compile(optimizer='rmsprop', loss='categorical_crossentropy', metrics=['accuracy'])
network.fit(x=x_train, y=y_train, batch_size=128, epochs=5)
test_loss, test_acc = network.evaluate(x=x_test, y=y_test)
print(network.summary())
print('test_acc:', test_acc)
print('test_loss:', test_loss)
更多推荐
所有评论(0)