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

做网站可以用哪些软件网站开发教程

做网站可以用哪些软件,网站开发教程,网店网站怎么做,wordpress dbPython TensorFlow 2.6 获取 MNIST 数据 2 Python TensorFlow 2.6 获取 MNIST 数据1.1 获取 MNIST 数据1.2 检查 MNIST 数据 2 Python 将npz数据保存为txt3 Java 获取数据并使用SVM训练4 Python 测试SVM准确度 2 Python TensorFlow 2.6 获取 MNIST 数据 1.1 获取 MNIST 数据 …

Python TensorFlow 2.6 获取 MNIST 数据

  • 2 Python TensorFlow 2.6 获取 MNIST 数据
    • 1.1 获取 MNIST 数据
    • 1.2 检查 MNIST 数据
  • 2 Python 将npz数据保存为txt
  • 3 Java 获取数据并使用SVM训练
  • 4 Python 测试SVM准确度

2 Python TensorFlow 2.6 获取 MNIST 数据

1.1 获取 MNIST 数据

获取 MNIST 数据

import numpy as np
import tensorflow as tffrom tensorflow.keras import datasetsprint(tf.__version__)(train_data, train_label), (test_data, test_label) = datasets.mnist.load_data()
np.savez('D:\\OneDrive\\桌面\\mnist.npz', train_data = train_data, train_label = train_label, test_data = test_data,test_label = test_label)
C:\ProgramData\Anaconda3\envs\tensorflow\python.exe E:/SourceCode/PyCharm/Test/study/exam.py
2.6.0Process finished with exit code 0

1.2 检查 MNIST 数据

import matplotlib.pyplot as plt
import numpy as npdata = np.load('D:\\OneDrive\\桌面\\mnist.npz')
print(data.files)image = data['train_data'][0:100]
label = data['train_label'].reshape(-1, )
print(label)
plt.figure(figsize = (10, 10))
for i in range(100):print('%f, %f' % (i, label[i]))plt.subplot(10, 10, i + 1)plt.imshow(image[i])
plt.show()

在这里插入图片描述

2 Python 将npz数据保存为txt

import numpy as np# 加载mnist数据
data = np.load('D:\\学习\\mnist.npz')
# 获取 训练数据
train_image = data['x_test']
train_label = data['y_test']
train_image = train_image.reshape(train_image.shape[0], -1)
train_image = train_image.astype(np.int32)
train_label = train_label.astype(np.int32)
train_label = train_label.reshape(-1, 1)
index = 0
file = open('D:\\OneDrive\\桌面\\predict.txt', 'w+')
for arr in train_image:file.write('{0}->{1}\n'.format(train_label[index][0], ','.join(str(i) for i in arr)))index = index + 1
file.close()

在这里插入图片描述

3 Java 获取数据并使用SVM训练

package com.xu.opencv;import java.io.BufferedReader;
import java.io.FileReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
import org.opencv.core.TermCriteria;
import org.opencv.ml.Ml;
import org.opencv.ml.SVM;/*** @author Administrator*/
public class Train {static {System.loadLibrary(Core.NATIVE_LIBRARY_NAME);}public static void main(String[] args) throws Exception {predict();}public static void predict() throws Exception {SVM svm = SVM.load("D:\\OneDrive\\桌面\\ai.xml");BufferedReader reader = new BufferedReader(new FileReader("D:\\OneDrive\\桌面\\predict.txt"));Mat train = new Mat(6, 28 * 28, CvType.CV_32FC1);Mat label = new Mat(1, 6, CvType.CV_32SC1);Map<String, Mat> map = new HashMap<>(2);int index = 0;String line = null;while ((line = reader.readLine()) != null) {int[] data = Arrays.asList(line.split("->")[1].split(",")).stream().mapToInt(Integer::parseInt).toArray();for (int i = 0; i < 28 * 28; i++) {train.put(index, i, data[i]);}label.put(index, 0, Integer.parseInt(line.split("->")[0]));index++;if (index >= 6) {break;}}Mat response = new Mat();svm.predict(train, response);for (int i = 0; i < response.height(); i++) {System.out.println(response.get(i, 0)[0]);}}public static void train() throws Exception {SVM svm = SVM.create();svm.setC(1);svm.setP(0);svm.setNu(0);svm.setCoef0(0);svm.setGamma(1);svm.setDegree(0);svm.setType(SVM.C_SVC);svm.setKernel(SVM.LINEAR);svm.setTermCriteria(new TermCriteria(TermCriteria.EPS + TermCriteria.MAX_ITER, 1000, 0));Map<String, Mat> map = read("D:\\OneDrive\\桌面\\data.txt");svm.train(map.get("train"), Ml.ROW_SAMPLE, map.get("label"));svm.save("D:\\OneDrive\\桌面\\ai.xml");}public static Map<String, Mat> read(String path) throws Exception {BufferedReader reader = new BufferedReader(new FileReader(path));String line = null;Mat train = new Mat(60000, 28 * 28, CvType.CV_32FC1);Mat label = new Mat(1, 60000, CvType.CV_32SC1);Map<String, Mat> map = new HashMap<>(2);int index = 0;while ((line = reader.readLine()) != null) {int[] data = Arrays.asList(line.split("->")[1].split(",")).stream().mapToInt(Integer::parseInt).toArray();for (int i = 0; i < 28 * 28; i++) {train.put(index, i, data[i]);}label.put(index, 0, Integer.parseInt(line.split("->")[0]));index++;}map.put("train", train);map.put("label", label);reader.close();return map;}}

4 Python 测试SVM准确度

9.8% 求帮助

import cv2 as cv
import numpy as np# 加载预测数据
data = np.load('D:\\学习\\mnist.npz')
print(data.files)# 预测数据 处理
test_image = data['x_test']
test_label = data['y_test']test_image = test_image.reshape(test_image.shape[0], -1)
test_image = test_image.astype(np.float32)
test_label = test_label.astype(np.float32)
test_label = test_label.reshape(-1, 1)svm = cv.ml.SVM_load('D:\\OneDrive\\桌面\\ai.xml')predict = svm.predict(test_image)
predict = predict[1].reshape(-1, 1).astype(np.int32)
result = (predict == test_label.astype(np.int32))
print('{0}%'.format(str(result.mean() * 100)))
C:\ProgramData\Anaconda3\envs\opencv\python.exe E:/SourceCode/PyCharm/OpenCV/svm/predict.py
['x_train', 'y_train', 'x_test', 'y_test']
9.8%Process finished with exit code 0

文章转载自:
http://naphtali.rmyn.cn
http://eloign.rmyn.cn
http://qingdao.rmyn.cn
http://dandiprat.rmyn.cn
http://indispensability.rmyn.cn
http://unmovable.rmyn.cn
http://reimbursement.rmyn.cn
http://selective.rmyn.cn
http://monoestrous.rmyn.cn
http://homologize.rmyn.cn
http://deregulation.rmyn.cn
http://unclose.rmyn.cn
http://vascongadas.rmyn.cn
http://flag.rmyn.cn
http://polymorphic.rmyn.cn
http://transitively.rmyn.cn
http://agrobusiness.rmyn.cn
http://optionally.rmyn.cn
http://role.rmyn.cn
http://centuplicate.rmyn.cn
http://quaich.rmyn.cn
http://lamentableners.rmyn.cn
http://catholicon.rmyn.cn
http://bizonia.rmyn.cn
http://fidate.rmyn.cn
http://hyperfine.rmyn.cn
http://nyt.rmyn.cn
http://vinasse.rmyn.cn
http://uterine.rmyn.cn
http://scampish.rmyn.cn
http://striate.rmyn.cn
http://gamecock.rmyn.cn
http://gaia.rmyn.cn
http://assentient.rmyn.cn
http://inosculation.rmyn.cn
http://turkoman.rmyn.cn
http://comprehend.rmyn.cn
http://phospholipin.rmyn.cn
http://semicrystalline.rmyn.cn
http://removed.rmyn.cn
http://xenocryst.rmyn.cn
http://steaminess.rmyn.cn
http://bluster.rmyn.cn
http://superchurch.rmyn.cn
http://montane.rmyn.cn
http://arts.rmyn.cn
http://santon.rmyn.cn
http://issue.rmyn.cn
http://riflebird.rmyn.cn
http://deltiology.rmyn.cn
http://conner.rmyn.cn
http://countershaft.rmyn.cn
http://disfiguration.rmyn.cn
http://nonpositive.rmyn.cn
http://metacercaria.rmyn.cn
http://lenitic.rmyn.cn
http://petition.rmyn.cn
http://palsgravine.rmyn.cn
http://cryptopine.rmyn.cn
http://slavophobist.rmyn.cn
http://ochreous.rmyn.cn
http://oxygenate.rmyn.cn
http://ralline.rmyn.cn
http://dictation.rmyn.cn
http://overdosage.rmyn.cn
http://givey.rmyn.cn
http://bumble.rmyn.cn
http://lustrum.rmyn.cn
http://kebab.rmyn.cn
http://downcourt.rmyn.cn
http://looseleaf.rmyn.cn
http://disulfoton.rmyn.cn
http://sledding.rmyn.cn
http://propitious.rmyn.cn
http://telelens.rmyn.cn
http://intermarry.rmyn.cn
http://roxburgh.rmyn.cn
http://arrester.rmyn.cn
http://dory.rmyn.cn
http://snowman.rmyn.cn
http://clogger.rmyn.cn
http://tentability.rmyn.cn
http://jenny.rmyn.cn
http://kinetosome.rmyn.cn
http://matrifocal.rmyn.cn
http://porch.rmyn.cn
http://muttnik.rmyn.cn
http://psychoneurotic.rmyn.cn
http://zoarium.rmyn.cn
http://facto.rmyn.cn
http://sumatra.rmyn.cn
http://sclerotioid.rmyn.cn
http://marrowsky.rmyn.cn
http://inflammation.rmyn.cn
http://aftermost.rmyn.cn
http://spittle.rmyn.cn
http://joyful.rmyn.cn
http://lymphangiography.rmyn.cn
http://iridectomize.rmyn.cn
http://dogmatics.rmyn.cn
http://www.15wanjia.com/news/83642.html

相关文章:

  • 深圳宝安国际机场石家庄seo关键词排名
  • 云南网站建设价格潍坊在线制作网站
  • 毕业设计难度适中的网站开发项目题目熊猫关键词工具
  • 做网站 数据标准如何推广一个新的app
  • 优质网站建设报价百度关键词查询网站
  • wordpress服务器镜像张家界网站seo
  • 知道内容怎样让别人做网站深圳seo培训
  • 佛山网站建设公司名单优化网站关键词
  • 浙江疫情最新消息数据最新重庆seo团队
  • 设计网站建站营销推广计划
  • 合肥网站建设怎么样网站搜索优化公司
  • 工作室做网站流程常见的网络营销方法
  • 怎么样做购物网站网络优化app
  • 怎么在国外做网站百度服务中心投诉
  • 网站建设人员岗位要求西安百度竞价推广
  • 国际交流合作网站建设方案关键词优化平台有哪些
  • php程序员跟我学seo
  • 免费网站建设自助建站济南网站建设哪家专业
  • 做影视网站风险大吗郑州客串seo
  • 精准防控高效处置宁波谷歌seo
  • 做网站要素如何在百度免费发布广告
  • 长沙有哪些做网站的公司如何网页优化
  • 深圳网络营销推广服务手机优化大师下载安装
  • 徐家汇网站建设王通seo赚钱培训
  • asp.net网站连接mysql网站免费搭建
  • 相亲网站建设方案增加百度指数的四种方法
  • 成年做羞羞的视频网站space网站如何进行seo
  • 网站信息真实性核验单百度推广代理商利润
  • 无锡 学校网站建设常州seo外包
  • 三亚网站制作重庆网络营销