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

怎么做好营销网站开发wordpress 4.8正式版

怎么做好营销网站开发,wordpress 4.8正式版,营业推广方案怎么写,wordpress婚纱摄影主题文章目录 pytorch 神经网络训练demoResult参考来源 pytorch 神经网络训练demo 数据集#xff1a;MNIST 该数据集的内容是手写数字识别#xff0c;其分为两部分#xff0c;分别含有60000张训练图片和10000张测试图片 图片来源#xff1a;https://tensornews.cn/mnist_intr… 文章目录 pytorch 神经网络训练demoResult参考来源 pytorch 神经网络训练demo 数据集MNIST 该数据集的内容是手写数字识别其分为两部分分别含有60000张训练图片和10000张测试图片 图片来源https://tensornews.cn/mnist_intro/ 神经网络RNN, GRU, LSTM # Imports import torch import torch.nn as nn import torch.optim as optim import torch.nn.functional as F from torch.utils.data import DataLoader import torchvision.datasets as datasets import torchvision.transforms as transforms# Set device device torch.device(cuda if torch.cuda.is_available() else cpu)# Hyperparameters input_size 28 sequence_length 28 num_layers 2 hidden_size 256 num_classes 10 learning_rate 0.001 batch_size 64 num_epochs 2# Create a RNN class RNN(nn.Module):def __init__(self, input_size, hidden_size, num_layers, num_classes):super(RNN, self).__init__()self.hidden_size hidden_sizeself.num_layers num_layersself.rnn nn.RNN(input_size, hidden_size, num_layers, batch_firstTrue)self.fc nn.Linear(hidden_size*sequence_length, num_classes) # fully connecteddef forward(self, x):h0 torch.zeros(self.num_layers, x.size(0), self.hidden_size).to(device)# Forward Propout, _ self.rnn(x, h0)out out.reshape(out.shape[0], -1)out self.fc(out)return out# Create a GRU class RNN_GRU(nn.Module):def __init__(self, input_size, hidden_size, num_layers, num_classes):super(RNN_GRU, self).__init__()self.hidden_size hidden_sizeself.num_layers num_layersself.gru nn.GRU(input_size, hidden_size, num_layers, batch_firstTrue)self.fc nn.Linear(hidden_size*sequence_length, num_classes) # fully connecteddef forward(self, x):h0 torch.zeros(self.num_layers, x.size(0), self.hidden_size).to(device)# Forward Propout, _ self.gru(x, h0)out out.reshape(out.shape[0], -1)out self.fc(out)return out# Create a LSTM class RNN_LSTM(nn.Module):def __init__(self, input_size, hidden_size, num_layers, num_classes):super(RNN_LSTM, self).__init__()self.hidden_size hidden_sizeself.num_layers num_layersself.lstm nn.LSTM(input_size, hidden_size, num_layers, batch_firstTrue)self.fc nn.Linear(hidden_size*sequence_length, num_classes) # fully connecteddef forward(self, x):h0 torch.zeros(self.num_layers, x.size(0), self.hidden_size).to(device)c0 torch.zeros(self.num_layers, x.size(0), self.hidden_size).to(device)# Forward Propout, _ self.lstm(x, (h0, c0))out out.reshape(out.shape[0], -1)out self.fc(out)return out# Load data train_dataset datasets.MNIST(rootdataset/, trainTrue, transformtransforms.ToTensor(),downloadTrue) train_loader DataLoader(datasettrain_dataset, batch_sizebatch_size, shuffleTrue) test_dataset datasets.MNIST(rootdataset/, trainFalse, transformtransforms.ToTensor(),downloadTrue) test_loader DataLoader(datasettest_dataset, batch_sizebatch_size, shuffleTrue)# Initialize network 选择一个即可 model RNN(input_size, hidden_size, num_layers, num_classes).to(device) # model RNN_GRU(input_size, hidden_size, num_layers, num_classes).to(device) # model RNN_LSTM(input_size, hidden_size, num_layers, num_classes).to(device)# Loss and optimizer criterion nn.CrossEntropyLoss() optimizer optim.Adam(model.parameters(), lrlearning_rate)# Train network for epoch in range(num_epochs):# data: images, targets: labelsfor batch_idx, (data, targets) in enumerate(train_loader):# Get data to cuda if possibledata data.to(device).squeeze(1) # 删除一个张量中所有维数为1的维度 (N, 1, 28, 28) - (N, 28, 28)targets targets.to(device)# forwardscores model(data) # 64*10loss criterion(scores, targets)# backwardoptimizer.zero_grad()loss.backward()# gradient descent or adam stepoptimizer.step()# Check accuracy on training test to see how good our model def check_accuracy(loader, model):if loader.dataset.train:print(Checking accuracy on training data)else:print(Checking accuracy on test data)num_correct 0num_samples 0model.eval()with torch.no_grad(): # 不计算梯度for x, y in loader:x x.to(device).squeeze(1)y y.to(device)# x x.reshape(x.shape[0], -1) # 64*784scores model(x)# 64*10_, predictions scores.max(dim1) #dim1表示对每行取最大值每行代表一个样本。num_correct (predictions y).sum()num_samples predictions.size(0) # 64print(fGot {num_correct} / {num_samples} with accuracy {float(num_correct)/float(num_samples)*100:.2f}%)model.train()check_accuracy(train_loader, model) check_accuracy(test_loader, model) Result RNN Result Checking accuracy on training data Got 57926 / 60000 with accuracy 96.54% Checking accuracy on test data Got 9640 / 10000 with accuracy 96.40%GRU Result Checking accuracy on training data Got 59058 / 60000 with accuracy 98.43% Checking accuracy on test data Got 9841 / 10000 with accuracy 98.41%LSTM Result Checking accuracy on training data Got 59248 / 60000 with accuracy 98.75% Checking accuracy on test data Got 9849 / 10000 with accuracy 98.49%参考来源 【1】https://www.youtube.com/watch?vGl2WXLIMvKAlistPLhhyoLH6IjfxeoooqP9rhU3HJIAVAJ3Vzindex5
http://www.pierceye.com/news/223237/

相关文章:

  • 英迈思做的网站怎么样网站做m版
  • 通州设计网站建设城市宣传片制作公司
  • 南安网站设计网站创意
  • 建设部网站造价注册seo优化易下拉霸屏
  • 西安网站外包上海网站被查
  • 建简单网站高端建筑铝型材
  • wordpress 网站访问量高端建筑物图片
  • seo网站推广目的WordPress灯箱效果移动适配
  • 梅州正规的免费建站微信应用开发公司
  • 百度做网站教程网站建设与维护ppt
  • 化妆品网站建设方案做咩有D网站响网吧上不了
  • 网站 迁移房地产销售基础知识大全
  • 门户网站建设汇报材料网站开发与制作中期报告
  • 网站建设可以自己弄吗知乎做网站必须要服务器吗
  • 怎么制作自己的小程序专业seo整站优化
  • 做网站是干什么用的苏宁易购网站上的营销页面
  • 浪网站制作网站开发是无形资产
  • 做阿里巴巴网站可以贷款吗seo如何快速排名百度首页
  • 公司做网站都咨询哪些问题网站平台建设视频教学
  • 西安电子商务网站建设网站里面的链接怎么做
  • 郑州陆港开发建设有限公司网站58招商加盟项目
  • 徐州高端网站建设个人网站设计首页界面
  • 山西企业建站系统平台关键词 优化 网站
  • 地板网站建设方案有什么做美食的网站
  • 网站建设丶金手指专业网站幻灯片 字段
  • 网站开发技术总结干完房产中介整个人废了
  • iis建站安装wordpress对网站建设的评价语
  • 网站开发网站建设公司二手房网
  • 72建站网如何建设一个药材网站做网站的费用 可以抵扣吗
  • 四川通信建设工程有限公司网站做企业网站需要服务器么