tensorflow安装https://zhuanlan.zhihu.com/p/34602355
可能好用?
import python as tf
这个命令可以运行就算安装好了
--------------------------------------------------------------------------
Google Tensorflow 官方教程地址https://www.tensorflow.org/tutorials
本文只作为官方文档的学习笔记和补充
---------------------------------------------------------------------------
1.面向初学者的快速入门没有任何问题,直接复制代码跑就可以了
2.Keras机器学习基础知识
2.1基本图像分类
# Helper libraries
import numpy as np
import matplotlib.pyplot as plt
这部分代码可能报错No module named 'matplotlib',解决方法就是用pip安装一下matplotlib
参考这篇文章https://blog.csdn.net/weixin_41640583/article/details/86552766
1. 激活tensorflow环境:【activate tensorflow】
2. 安装matplotlib:【pip install matplotlib】
model = keras.Sequential([
keras.layers.Flatten(input_shape=(28, 28)),
keras.layers.Dense(128, activation='relu'),
keras.layers.Dense(10, activation='softmax')
])
这部分代码有些需要知道的:relu是一个激活函数,类似sigmoid。https://blog.csdn.net/dhaiuda/article/details/100079475
softmax是一个分类函数,和logistic function的区别是:如果分类是互斥的,那么softmax更好,如果不是,logistic function更好https://blog.csdn.net/bitcarmanlee/article/details/82320853
model.fit(train_images, train_labels, epochs=10)
test_loss, test_acc = model.evaluate(test_images, test_labels, verbose=2)
print('\nTest accuracy:', test_acc)
训练和测试出来的准确性有一点差异,训练时的准确性大概0.9左右,测试时0.87左右,这个差异的overfitting导致的。官方原文:It turns out that the accuracy on the test dataset is a little less than the accuracy on the training dataset. This gap between training accuracy and test accuracy represents overfitting.