栏目分类:
子分类:
返回
文库吧用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
文库吧 > IT > 软件开发 > 后端开发 > Python

MachineLearning

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

MachineLearning

Machine Learning -tensorflow –环境 编辑器上安装:

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/

使用免费线上资源,免费CPU,GPU Colab Kaggle kaggle使用时的小细节

文件压缩包的下载和解压

!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,最主要是训练素材的数量,
以下便是一个训练的草图

–CNN(convolutional neural network) convolution and pooling convolution

过滤器中的数值与像素对应位置相乘

2,3图分别为着重提取纵向与横向特征
其过滤器如下

#  filter = [[-1, -2, -1],[0, 0, 0],[1, 2, 1]]
#  filter = [[-1, 0 ,1],[-2, 0, 2],[-1, 0, 1]]

下面便是分别是原图,提取纵向,提取横向,池化的结果

pooling

Max pooling 增强特征,减少数据

未完,待续、、、
均为个人见解,勿喷、、、

转载请注明:文章转载自 www.wk8.com.cn
本文地址:https://www.wk8.com.cn/it/1038409.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 wk8.com.cn

ICP备案号:晋ICP备2021003244-6号