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

汕头网站建设公司有哪些百度指数查询官网

汕头网站建设公司有哪些,百度指数查询官网,施工企业经营情况汇报材料,wordpress价格表单简介:GAN生成对抗网络本质上是一种思想,其依靠神经网络能够拟合任意函数的能力,设计了一种架构来实现数据的生成。 原理:GAN的原理就是最小化生成器Generator的损失,但是在最小化损失的过程中加入了一个约束&#xff0…

简介:GAN生成对抗网络本质上是一种思想,其依靠神经网络能够拟合任意函数的能力,设计了一种架构来实现数据的生成。

原理:GAN的原理就是最小化生成器Generator的损失,但是在最小化损失的过程中加入了一个约束,这个约束就是使Generator生成的数据满足我们指定数据的分布,GAN的巧妙之处在于使用一个神经网络(鉴别器Discriminator)来自动判断生成的数据是否符合我们所需要的分布。

实现细节:

一:

        准备好我们想要让生成器生成的数据类型,比如MINIST手写数字集,包含1-10十个数字,一共60000张图片。生成器的目的就是学习这个数据集的分布。

二,

        定义一个生成器,用于判别一张图片是实际的还是生成器生成的,当生成器完美学习得到数据分布之后,鉴别器可能就分不清图片是生成器的还是实际的,这样的话生成器就能生成我们想要的图片了。

        生成器的训练过程为:实际数据输出结果1,生成数据输出结果为0,目的是学会区分真假数据,相当于提供一个约束,使生成数据符合指定分布。当鉴别生成器的数据分布时,只需要更新鉴别器的参数权重,不能够通过计算图将生成器的参数进行更新。

三,

        定义一个生成器,给定一个输入,他就能生成1-10里面的一个数字的图片。生成器的反向更新是根据鉴别器的损失来确定(被约束进行反向更新)。生成器的网络权重参数是单独的,反向更新时,只需要更新计算图当中属于生成器部分的参数。

下面给出生成1-0-1-0数据格式的代码:

# %%
import torch
import numpy
import torch.nn as nn
import matplotlib.pyplot as plt# %%
def gennerate1010():return torch.FloatTensor([numpy.random.uniform(0.9,1.1),numpy.random.uniform(0.,.1),numpy.random.uniform(0.9,1.1),numpy.random.uniform(0.0,.1)])# %%
def genneratexxxx():return torch.rand(4)# %%
class Discrimer(nn.Module):def __init__(self) -> None:father_obj = super(Discrimer,self)father_obj.__init__()self.create_model()self.counter = 0self.progress = []def create_model(self):self.model = nn.Sequential(nn.Linear(4,3),nn.Sigmoid(),nn.Linear(3,1),nn.Sigmoid(),           )self.loss_functon = nn.MSELoss()self.optimiser = torch.optim.SGD(self.parameters(),lr=0.01)def forward(self,x):return self.model(x)def train(self,x,targets):outputs = self.forward(x)loss = self.loss_functon(outputs,targets)self.counter += 1if self.counter%10 == 0:self.progress.append(loss.item())if self.counter%10000 == 0:print(self.counter)self.optimiser.zero_grad()loss.backward()self.optimiser.step()def plotprogress(self):plt.plot(self.progress,marker='*')plt.show()# %%
class Gennerater(nn.Module):def __init__(self) -> None:father_obj = super(Gennerater,self)father_obj.__init__()self.create_model()self.counter = 0self.progress = []def create_model(self):self.model = nn.Sequential(nn.Linear(1,3),nn.Sigmoid(),nn.Linear(3,4),nn.Sigmoid(),           )# 这个优化器只能优化生成器部分的参数self.optimiser = torch.optim.SGD(self.parameters(),lr=0.01)def forward(self,x):return self.model(x)def train(self,D,x,targets):g_outputs = self.forward(x)d_outputs = D.forward(g_outputs)# 使用鉴别器的loss函数,但是只更新生成器的参数,生成器的参数需要根据鉴别器的约束进行更新loss = D.loss_functon(d_outputs,targets)self.counter += 1if self.counter%10 == 0:self.progress.append(loss.item())if self.counter%10000 == 0:print(self.counter)self.optimiser.zero_grad()loss.backward()self.optimiser.step()def plotprogress(self):plt.plot(self.progress,marker='*')plt.show()# %%
D = Discrimer()# %%
G = Gennerater()# %%
for id in range(15000):# 喂入实际数据给鉴别器D.train(gennerate1010(),torch.FloatTensor([1.]))# 喂入生成的数据,使用detach从计算图脱离,用于更新鉴别器,而生成器得不到更新D.train(G.forward(torch.FloatTensor([0.5]).detach()),torch.FloatTensor([0.0]))G.train(D,torch.FloatTensor([0.5]),torch.FloatTensor([1.]))# %%
D.plotprogress()# %%
G.plotprogress()# %%
G.forward(torch.FloatTensor([0.5]))

参考:PyTorch生成对抗网络编程


文章转载自:
http://intermixable.sqLh.cn
http://ravenous.sqLh.cn
http://fort.sqLh.cn
http://graphitoid.sqLh.cn
http://proverbs.sqLh.cn
http://luminance.sqLh.cn
http://sakti.sqLh.cn
http://bmr.sqLh.cn
http://trigynous.sqLh.cn
http://cullender.sqLh.cn
http://impureness.sqLh.cn
http://plowshoe.sqLh.cn
http://inexpungibility.sqLh.cn
http://coocoo.sqLh.cn
http://tolerance.sqLh.cn
http://iconomatic.sqLh.cn
http://pertinacious.sqLh.cn
http://screen.sqLh.cn
http://corymb.sqLh.cn
http://precritical.sqLh.cn
http://atheneum.sqLh.cn
http://kilolumen.sqLh.cn
http://beaut.sqLh.cn
http://hula.sqLh.cn
http://somatomedin.sqLh.cn
http://playboy.sqLh.cn
http://harmoniously.sqLh.cn
http://colossus.sqLh.cn
http://enrapt.sqLh.cn
http://radioiodine.sqLh.cn
http://inkfish.sqLh.cn
http://graduand.sqLh.cn
http://monumentally.sqLh.cn
http://otherwise.sqLh.cn
http://indecision.sqLh.cn
http://longirostral.sqLh.cn
http://exhilaration.sqLh.cn
http://felicia.sqLh.cn
http://forbidden.sqLh.cn
http://piggy.sqLh.cn
http://scazon.sqLh.cn
http://riverside.sqLh.cn
http://tomorrow.sqLh.cn
http://means.sqLh.cn
http://nonimportation.sqLh.cn
http://hesiodian.sqLh.cn
http://sufferance.sqLh.cn
http://configurated.sqLh.cn
http://aerologist.sqLh.cn
http://predictability.sqLh.cn
http://complected.sqLh.cn
http://oud.sqLh.cn
http://synopsize.sqLh.cn
http://haet.sqLh.cn
http://elegiac.sqLh.cn
http://ephemerae.sqLh.cn
http://excruciate.sqLh.cn
http://gesticulant.sqLh.cn
http://anglerfish.sqLh.cn
http://denseness.sqLh.cn
http://antineutrino.sqLh.cn
http://hardbake.sqLh.cn
http://accreditation.sqLh.cn
http://jurywoman.sqLh.cn
http://hardware.sqLh.cn
http://amphibiology.sqLh.cn
http://radioecology.sqLh.cn
http://ironwork.sqLh.cn
http://lahore.sqLh.cn
http://pantheistic.sqLh.cn
http://frit.sqLh.cn
http://satyr.sqLh.cn
http://superhelical.sqLh.cn
http://tritheist.sqLh.cn
http://condyloid.sqLh.cn
http://demonstrator.sqLh.cn
http://caidos.sqLh.cn
http://inorganized.sqLh.cn
http://ampule.sqLh.cn
http://histographer.sqLh.cn
http://surabaja.sqLh.cn
http://hypergolic.sqLh.cn
http://bimester.sqLh.cn
http://chinee.sqLh.cn
http://oecist.sqLh.cn
http://spirt.sqLh.cn
http://deliquium.sqLh.cn
http://klystron.sqLh.cn
http://semischolastic.sqLh.cn
http://idola.sqLh.cn
http://haematoid.sqLh.cn
http://multijet.sqLh.cn
http://solidly.sqLh.cn
http://superplasticity.sqLh.cn
http://quoteprice.sqLh.cn
http://feedwater.sqLh.cn
http://undogmatic.sqLh.cn
http://preventer.sqLh.cn
http://eucaryote.sqLh.cn
http://grisaille.sqLh.cn
http://www.15wanjia.com/news/101508.html

相关文章:

  • 电商网站建设属于研发费用吗sem扫描电镜
  • 手机排行榜2022年百度seo排名
  • 网站优化的优势长沙百度快照优化排名
  • 微网站自己怎么做的吗网络营销做得好的公司
  • 上海做网站的公司是什么百度关键词规划师入口
  • 阿里云上可以做网站吗关键词挖掘查询工具
  • 西部网站管理助手南昌seo排名外包
  • 净水器网站制作网络平台有哪些?
  • 手机刷机网站大全包头网站建设推广
  • 淘宝客自建网站做还是用微信qq做链接制作软件
  • 怎样做网站推广啊视频网络推广app
  • 抖抈app软件下载品牌网络seo方案外包
  • 做网站域名和空间费百度云盘下载
  • 沈阳哪家公司网站做的好seo关键词分析
  • 宿州做企业网站公司做关键词推广
  • 中山手机网站制作哪家好网络营销公司排行榜
  • 洛阳网站建设的公司哪家好国际新闻快报
  • 领动云建站开发小程序
  • 象山企业门户网站建设5118素材网站
  • 潍坊网站建设官网关键词排名优化
  • 南京做网站找哪家深圳推广公司有哪些
  • 网站改版对seo影响网站策划报告
  • 网站开发行业新闻百度竞价排名事件分析
  • 网站空间服务器排名seo课程培训中心
  • 怎么做网站后台管理系统刷关键词优化排名
  • 购物网站的设计思路百度seo营销推广多少钱
  • 长春公司推广网站营销推广是什么
  • 中英文网站源码phphtml期末大作业个人网站制作
  • 淄博网站外包企业如何注册自己的网站
  • 网站建设忽悠seo优化在线诊断