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

深圳做公司网站推广的国外引流推广平台

深圳做公司网站推广的,国外引流推广平台,做国际网站多少钱,网站制作公司上海Python实现神经网络有多种方法。这里我们使用keras框架。你必须安装 tensorflow或theano, 和 keras然后才能实现神经网络。1. 下载数据集并提取训练和测试集(见“NN.ipynb”)from keras.datasets import mnistimport matplotlib.pyplot as plt%matplotlib inline# load (downlo…

Python实现神经网络有多种方法。这里我们使用keras框架。你必须安装 tensorflow或theano, 和 keras然后才能实现神经网络。

1. 下载数据集并提取训练和测试集(见“NN.ipynb”)

from keras.datasets import mnist

import matplotlib.pyplot as plt

%matplotlib inline

# load (downloaded if needed) the MNIST dataset

(X_train, y_train), (X_test, y_test) = mnist.load_data()

# plot 4 images as gray scale

plt.subplot(221)

plt.imshow(X_train[0], cmap=plt.get_cmap('gray'))

plt.subplot(222)

plt.imshow(X_train[1], cmap=plt.get_cmap('gray'))

plt.subplot(223)

plt.imshow(X_train[2], cmap=plt.get_cmap('gray'))

plt.subplot(224)

plt.imshow(X_train[3], cmap=plt.get_cmap('gray'))

# show the plot

plt.show()

4-18. 输出

2. 导入相关包:

import numpy as np

from keras.datasets import mnist

from keras.models import Sequential

from keras.layers import Dense

from keras.layers import Dropout

from keras.utils import np_utils

3. 预处理数据集:

num_pixels = X_train.shape[1] * X_train.shape[2]

# reshape the inputs so that they can be passed to the

vanilla NN

X_train = X_train.reshape(X_train.shape[0],num_pixels

).astype('float32')

X_test = X_test.reshape(X_test.shape[0],num_pixels).

astype('float32')

# scale inputs

X_train = X_train / 255

X_test = X_test / 255

# one hot encode the output

y_train = np_utils.to_categorical(y_train)

y_test = np_utils.to_categorical(y_test)

num_classes = y_test.shape[1]

4. 构建模型:

# building the model

model = Sequential()

# add 1000 units in the hidden layer

# apply relu activation in hidden layer

model.add(Dense(1000, input_dim=num_pixels,activation='relu'))

# initialize the output layer

model.add(Dense(num_classes, activation='softmax'))

# compile the model

model.compile(loss='categorical_crossentropy',optimizer='adam', metrics=['accuracy'])

# extract the summary of model

model.summary()

5. 运行模型:

model.fit(X_train, y_train, validation_data=(X_test,

y_test), epochs=5, batch_size=1024, verbose=1)

注意随着epochs增加, 测试集的准确率也增加。另外在keras里我们只要在第一层指明输入的维,它会自己动的推出余下各层的维。

http://www.dtcms.com/wzjs/204152.html

相关文章:

  • cad二次开发网站兰州网站seo诊断
  • 小说网站如何做书源巨量引擎
  • 去哪儿网站开发怎么样把广告做在百度上
  • photoshop电脑版seo专业培训seo专业培训
  • 诺尔诺达网站建设品牌seo推广咨询
  • 海口疫情最新动态seo系统培训课程
  • 合肥专业做网站的公司有哪些网站设计制作培训
  • 大连企业建设网站邯郸百度推广公司
  • 广州网站建设模板青岛seo杭州厂商
  • 陕西省建设厅网站安全员报名北京百度快速排名
  • 王稳庄网站建设百度收录申请入口
  • 宾馆做网站手机seo排名
  • 美国云主机网站手机创建网站教程
  • java做直播网站重庆网站推广软件
  • 惠州网站优化想要导航推广网页怎么做
  • 仙桃网站优化营销软文200字
  • 如何建设电商网站一键优化下载
  • 清华紫光是可以做网站的吗百度投流运营
  • 响应式网站建设的优势2020 惠州seo服务
  • 网站开发是前端吗99个创意营销方案
  • 淘宝客优惠券网站怎么做的网址
  • 猪八戒做网站 纠纷搜索引擎优化服务
  • 网站后台更新图片优化人员是什么意思
  • 做网站上海代做网页设计平台
  • 如何分析一个网站做的怎么样世界杯球队最新排名
  • 做网站广告多少钱男生短期培训就业
  • 淄博市建设局网站首页电子商务
  • 电子商务网站规划建设与管理刷神马网站优化排名
  • 新手做网站详细步骤2022年最近十大新闻
  • 路由侠怎么做网站映射网站查询域名