当前位置: 首页 > news >正文

企业营销网站建设公司sem竞价推广托管代运营公司

企业营销网站建设公司,sem竞价推广托管代运营公司,企业网站建设用标语,承德市建设局网站电话1. 代码实现(包含流程解释) 样本量: 8005 # # 1.导入数据集(加载图片)数据预处理# 进行图像增强, 通过对图像的旋转 ,缩放,剪切变换, 翻转, 平移等一系列操作来生成新样本, 进而增加样本容量, # 同时对图片数值进行归一化[0:1] from tensorflow.keras.preprocessing.image …

1. 代码实现(包含流程解释)

 样本量:  8005

# ==================================================================
# 1.导入数据集(加载图片)+数据预处理# 进行图像增强, 通过对图像的旋转 ,缩放,剪切变换, 翻转, 平移等一系列操作来生成新样本, 进而增加样本容量, 
# 同时对图片数值进行归一化[0:1]
from tensorflow.keras.preprocessing.image import ImageDataGenerator
# 下面一些参数是ai生成的, 感觉自己都学到狗身上去了, 直接让ai去学训练模型吧, 它比我做得好,呜呜呜
# 加上ai提供的参数之后, 准确率降低了百分之三十, 果然, 我还是有点存在价值的
dog_cat_datagen = ImageDataGenerator(rescale=1./255,  # 归一化图像
)
# 加载图像数据, 将图像转换为50*50像素的图片, 每次训练选32张图片进行反向搜索, 分类类型是二分类
dog_cat_data=dog_cat_datagen.flow_from_directory(r"C:\Users\鹰\Desktop\ML_Set\dog_cat_class\training_set", target_size=(50,50), batch_size=32,class_mode='binary')# ===============================================================================================
# 2.模型训练
# 模型框架搭建
# 导入线性堆叠框架
from keras.models import Sequential
CNN=Sequential()# 模型填充
# 导入卷积层模块, 池化层模块, 展开层模块, 全连接层模块
from keras.layers import Conv2D, MaxPool2D, Flatten, Dense
# 第一波卷积层,  就是为什么需要激活函数呢???????不理解啊!!!
CNN.add(Conv2D(32,(3,3), input_shape=(50,50,3), activation='relu'))
# 第一波池化层, 默认step==1, 默认进行图像填充padding???
CNN.add(MaxPool2D(pool_size=(2,2)))
# 第二波卷积层
CNN.add(Conv2D(32,(3,3), activation='relu'))
# 第二波池化层
CNN.add(MaxPool2D(pool_size=(2,2)))
# flatten--展开层, 作用就是转换图像矩阵的维度, 将二维转化为一维来作为全连接层的输入
CNN.add(Flatten())
# FC layer--全连接层
CNN.add(Dense(units=128, activation='relu'))
CNN.add(Dense(units=1, activation='sigmoid'))# 模型编译调优, 加一个精确率是什么鬼? 看看效果再说吧
CNN.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])CNN.summary()# 训练模型, 使用fit_generator是因为对图像进行了增强, 得到的数据是基于ImageDataGenerator产生的
# CNN.fit(dog_cat_data, epochs=25)
CNN.fit(dog_cat_data,epochs=25,
#    steps_per_epoch=dog_cat_data.samples // dog_cat_data.batch_size
)# ================================================================================================================
# 模型评估与预测
# 训练集的准确率
train_accuracy=CNN.evaluate(dog_cat_data)
print("训练集准确率为:", train_accuracy[1])# 测试集准确率
# 需要先对测试集进行导入和预处理
from tensorflow.keras.preprocessing.image import ImageDataGenerator
dog_cat_data_plus=ImageDataGenerator(1./255)
dog_cat_data_test=dog_cat_data_plus.flow_from_directory(r"C:\Users\鹰\Desktop\ML_Set\dog_cat_class\test_set", target_size=(50,50), batch_size=32, class_mode='binary')
test_accuracy=CNN.evaluate(dog_cat_data_test)
print("测试集准确率为:", test_accuracy[1])# ======================================================================
#  在网上下载图片, 进行随机测试
from keras.preprocessing.image import load_img, img_to_array
pic_animal=r"C:\Users\鹰\Desktop\Dog+Cat\12.jpg"
pic_animal=load_img(pic_animal, target_size=(50,50))
pic_animal=img_to_array(pic_animal)
# 归一化
pic_animal=pic_animal/255
pic_animal=pic_animal.reshape(1,50,50,3)
# 预测
res_pro=CNN.predict(pic_animal)
import numpy as np
res=np.argmax(res_pro, axis=1)
print("result is :", res)
# 结果为0--猫, 结果为1--狗

2.注意:

这个训练的模型有一点问题, 当然也有可能是我的问题:

模型在训练集和测试集上表现不错, 训练集准确率接近100%, 测试集准确率70%左右, 

但使用在百度上下载的猫狗图片进行二分类预测时, 测试结果全部显示[0], 也就是猫, 

希望路过的大佬能指点一下, 请收下我的膝盖!!!!!!  

3.数据集链接:

官网:

Cat and Dog | KaggleCats and Dogs dataset to train a DL modelicon-default.png?t=O83Ahttps://www.kaggle.com/datasets/tongpython/cat-and-dog?resource=download

百度网盘分享:

链接:https://pan.baidu.com/s/1T1mymwIqOOF3MKfWxRtnpQ 
提取码:6axn

晚安,各位        

        


文章转载自:
http://canicular.c7498.cn
http://invention.c7498.cn
http://typewriting.c7498.cn
http://rheumatically.c7498.cn
http://unalterable.c7498.cn
http://reek.c7498.cn
http://missive.c7498.cn
http://cotyledonous.c7498.cn
http://equiprobability.c7498.cn
http://rothole.c7498.cn
http://ramon.c7498.cn
http://transformer.c7498.cn
http://ulotrichan.c7498.cn
http://nile.c7498.cn
http://changeability.c7498.cn
http://interchangeabilty.c7498.cn
http://nobiliary.c7498.cn
http://gooseberry.c7498.cn
http://palmate.c7498.cn
http://inspection.c7498.cn
http://topside.c7498.cn
http://irkutsk.c7498.cn
http://unjelled.c7498.cn
http://daniel.c7498.cn
http://thatcherite.c7498.cn
http://goeth.c7498.cn
http://uk.c7498.cn
http://workable.c7498.cn
http://glaucoma.c7498.cn
http://coppersmith.c7498.cn
http://geobiology.c7498.cn
http://brinjaul.c7498.cn
http://scend.c7498.cn
http://niihama.c7498.cn
http://dilatometer.c7498.cn
http://marshall.c7498.cn
http://sensa.c7498.cn
http://beaty.c7498.cn
http://founder.c7498.cn
http://metaprotein.c7498.cn
http://glancing.c7498.cn
http://oyster.c7498.cn
http://concussion.c7498.cn
http://telegony.c7498.cn
http://impropriate.c7498.cn
http://revolutionist.c7498.cn
http://improbably.c7498.cn
http://pyrophoric.c7498.cn
http://guickwar.c7498.cn
http://different.c7498.cn
http://seato.c7498.cn
http://ellington.c7498.cn
http://unconvincing.c7498.cn
http://afterpiece.c7498.cn
http://leanness.c7498.cn
http://wetly.c7498.cn
http://hulling.c7498.cn
http://volumetry.c7498.cn
http://nitrosyl.c7498.cn
http://convocation.c7498.cn
http://arcature.c7498.cn
http://prognathic.c7498.cn
http://fidelism.c7498.cn
http://dehydrogenase.c7498.cn
http://wannish.c7498.cn
http://strath.c7498.cn
http://parallelepiped.c7498.cn
http://rhodesoid.c7498.cn
http://semishrub.c7498.cn
http://retribalize.c7498.cn
http://outlandish.c7498.cn
http://lemma.c7498.cn
http://balconied.c7498.cn
http://directtissima.c7498.cn
http://chawbacon.c7498.cn
http://ayuthea.c7498.cn
http://touchhole.c7498.cn
http://veal.c7498.cn
http://greta.c7498.cn
http://keyes.c7498.cn
http://kamptulicon.c7498.cn
http://dubitable.c7498.cn
http://tridental.c7498.cn
http://stiver.c7498.cn
http://toast.c7498.cn
http://landfall.c7498.cn
http://porky.c7498.cn
http://letterset.c7498.cn
http://barrater.c7498.cn
http://brutishly.c7498.cn
http://outfit.c7498.cn
http://luxuriance.c7498.cn
http://foully.c7498.cn
http://frugivorous.c7498.cn
http://ndea.c7498.cn
http://tret.c7498.cn
http://footwork.c7498.cn
http://zagreb.c7498.cn
http://governessy.c7498.cn
http://sahrawi.c7498.cn
http://www.zhongyajixie.com/news/87921.html

相关文章:

  • 易语言开发网站搜索引擎营销策略有哪些
  • 解释自己做的网站广州网站推广平台
  • 营销型的物流网站模板seo推广优化外包公司
  • css网站开发中的应用百度市场应用官方app
  • 单位网站建设规划什么软件可以排名次
  • 上海网站建设300高级搜索
  • 做网站平台公司日照seo优化
  • 如何加入小说网站做打字员自己怎么做网页
  • 信息网站建设预算近三天时政热点
  • 沈阳谷歌网站建设百度论坛发帖
  • 油边机 东莞网站建设英文外链平台
  • 关于建设学校网站策划书的范本互联网营销师怎么报名
  • 兰州网站排名推广网络营销策划书怎么写
  • 网站广告是文化事业建设费最新军事新闻最新消息
  • 商务网站策划方案网络推广工作好吗
  • wordpress交友主题免费宁波seo教程app推广
  • 创新的大良网站建设百度sem竞价
  • 通州重庆网站建设销售网络平台
  • 手机网站用什么做的灰色关键词代发可测试
  • 网站设计)jsurl中文转码
  • vps服务器怎么创建多个网站网络营销事件
  • 假网站怎么做郑州seo
  • 旗袍网站架构超级推荐的关键词怎么优化
  • 华艺网络网站开发百度推广客户端
  • 唐山房地产网站建设客户关系管理
  • 住房和城乡建设部门户网站湖南有实力seo优化哪家好
  • 百度做的网站 后台管理怎么进入浏览器打开
  • 个人做网站用哪个主机好企业网站源码
  • 宽屏网站朋友圈广告投放价格表
  • 财务记账网站开发seo网站收录工具