pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade tensorflow-gpu
国内镜像
清华:https://pypi.tuna.tsinghua.edu.cn/simple
阿里云:http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
华中理工大学:http://pypi.hustunique.com/
山东理工大学:http://pypi.sdutlinux.org/
豆瓣:http://pypi.douban.com/simple/
文件压缩包的下载和解压
!wget --no-check-certificate http://storage.googleapis.com/laurencemoroney-blog.appspot.com/validation-horse-or-human.zip -O /tmp/validation-horse-or-human.zip !wget --no-check-certificate http://storage.googleapis.com/laurencemoroney-blog.appspot.com/horse-or-human.zip -O /tmp/horse-or-human.zip import zipfile train = zipfile.ZipFile("/tmp/horse-or-human.zip") train.extractall(path="/tmp/horse-or-human") validation = zipfile.ZipFile("/tmp/validation-horse-or-human.zip") validation.extractall(path="/tmp/validation-horse-or-human")
kaggle的详细目录结果,_注意_并非只有working和input目录,并且kaggle也不是根目录,只是一个子目录
–基础程序结构下列小总结大部分来源于------Google官方TensorFlow系列视频
import tensorflow as tf ##载入数据 data_x = [] data_y = [] ##模型建立 model = tf.keras.Sequential() model.add() ##优化 model.compile(loss= '', optimizer='') ##训练 model.fit(data_x, data_y, epochs = )–构建神经元模型
#构造神经元模型 model = keras.Sequential([ keras.layers.Flatten(input_shape= (28,28)),#输入层 keras.layers.Dense(128,activation=tf.nn.relu),#中间层,128个神经元 keras.layers.Dense(10, activation = tf.nn.softmax)#输出层,10个神经元 ])
模型示意图
relu函数和softmax函数
过拟合(overfitting)由于训练次数过多,导致训练的loss出现如下变化
因此可使用callbacks进行处理,当满足需要的精度后,就跳出训练
在拟合某些非线性模型(此处主要指二次曲线,三次曲线等等)目前可以得出,通过调整神经元的数量units,激活函数activation,以及层数layers,最主要是训练素材的数量,
以下便是一个训练的草图
过滤器中的数值与像素对应位置相乘
2,3图分别为着重提取纵向与横向特征
其过滤器如下
# filter = [[-1, -2, -1],[0, 0, 0],[1, 2, 1]] # filter = [[-1, 0 ,1],[-2, 0, 2],[-1, 0, 1]]
下面便是分别是原图,提取纵向,提取横向,池化的结果
Max pooling 增强特征,减少数据
未完,待续、、、
均为个人见解,勿喷、、、