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

做网站全自动cpa引流企业营销策划包括哪些内容

做网站全自动cpa引流,企业营销策划包括哪些内容,网站推广服务方案,怎样做网络推广效果好视频🍨 本文为🔗365天深度学习训练营 中的学习记录博客🍖 原作者:K同学啊 目录 代码总结与心得 代码 关于CGAN的原理上节已经讲过,这次主要是编写代码加载上节训练后的模型来进行指定条件的生成 图像的生成其实只需要使用…
  • 🍨 本文为🔗365天深度学习训练营 中的学习记录博客
  • 🍖 原作者:K同学啊

目录

  • 代码
  • 总结与心得


代码

关于CGAN的原理上节已经讲过,这次主要是编写代码加载上节训练后的模型来进行指定条件的生成

图像的生成其实只需要使用Generator模型,判别器模型是在训练过程中才用的。

# 库引入
from torch.autograd import Variable
from torchvision.utils import save_image, make_grid
import matplotlib.pyplot as plt
import torch.nn as nn
import torch.optim as optim
import torchdevice = torch.device('cuda' if torch.cuda.is_available() else 'cpu')# 超参数
latent_dim = 100
n_classes = 3
embedding_dim = 100# 工具函数
def weights_init(m):classname = m.__class__.__name__if classname.find('Conv') != -1:torch.nn.init.normal_(m.weight, 0.0, 0.02)elif classname.find('BatchNorm') != -1:torch.nn.init.normal_(m.weight, 1.0, 0.02)torch.nn.init.zeros_(m.bias)# 模型
class Generator(nn.Module):def __init__(self):super().__init__()self.label_conditioned_generator = nn.Sequential(nn.Embedding(n_classes, embedding_dim),nn.Linear(embedding_dim, 16))self.latent = nn.Sequential(nn.Linear(latent_dim, 4*4*512),nn.LeakyReLU(0.2, inplace=True))self.model = nn.Sequential(nn.ConvTranspose2d(513, 64*8, 4, 2, 1, bias=False),nn.BatchNorm2d(64*8, momentum=0.1, eps=0.8),nn.ReLU(True),nn.ConvTranspose2d(64*8, 64*4, 4, 2, 1, bias=False),nn.BatchNorm2d(64*4, momentum=0.1, eps=0.8),nn.ReLU(True),nn.ConvTranspose2d(64*4, 64*2, 4, 2, 1, bias=False),nn.BatchNorm2d(64*2, momentum=0.1, eps=0.8),nn.ReLU(True),nn.ConvTranspose2d(64*2, 64*1, 4, 2, 1, bias=False),nn.BatchNorm2d(64*1, momentum=0.1, eps=0.8),nn.ReLU(True),nn.ConvTranspose2d(64*1, 3, 4, 2, 1, bias=False),nn.Tanh())def forward(self, inputs):noise_vector, label = inputslabel_output = self.label_conditioned_generator(label)label_output = label_output.view(-1, 1, 4, 4)latent_output = self.latent(noise_vector)latent_output = latent_output.view(-1, 512, 4, 4)concat = torch.cat((latent_output, label_output), dim=1)image = self.model(concat)return imagegenerator = Generator().to(device)
generator.apply(weights_init)
print(generator)
Generator((label_conditioned_generator): Sequential((0): Embedding(3, 100)(1): Linear(in_features=100, out_features=16, bias=True))(latent): Sequential((0): Linear(in_features=100, out_features=8192, bias=True)(1): LeakyReLU(negative_slope=0.2, inplace=True))(model): Sequential((0): ConvTranspose2d(513, 512, kernel_size=(4, 4), stride=(2, 2), padding=(1, 1), bias=False)(1): BatchNorm2d(512, eps=0.8, momentum=0.1, affine=True, track_running_stats=True)(2): ReLU(inplace=True)(3): ConvTranspose2d(512, 256, kernel_size=(4, 4), stride=(2, 2), padding=(1, 1), bias=False)(4): BatchNorm2d(256, eps=0.8, momentum=0.1, affine=True, track_running_stats=True)(5): ReLU(inplace=True)(6): ConvTranspose2d(256, 128, kernel_size=(4, 4), stride=(2, 2), padding=(1, 1), bias=False)(7): BatchNorm2d(128, eps=0.8, momentum=0.1, affine=True, track_running_stats=True)(8): ReLU(inplace=True)(9): ConvTranspose2d(128, 64, kernel_size=(4, 4), stride=(2, 2), padding=(1, 1), bias=False)(10): BatchNorm2d(64, eps=0.8, momentum=0.1, affine=True, track_running_stats=True)(11): ReLU(inplace=True)(12): ConvTranspose2d(64, 3, kernel_size=(4, 4), stride=(2, 2), padding=(1, 1), bias=False)(13): Tanh())
)
from numpy.random import randint, randn
from numpy import linspace
from matplotlib import pyplot, gridspec# 加载训练好的权重
generator.load_state_dict(torch.load('generator_epoch_300.pth'), strict=False)
# 关闭梯度积累
generator.eval()# 生成随机变量
interpolated = randn(100)
interpolated = torch.tensor(interpolated).to(device).type(torch.float32)# 生成条件变量
label = 0 # 生成第0个分类的图像
labels = torch.ones(1) * label
labels = labels.to(device).unsqueeze(1).long()# 执行生成
predictions = generator((interpolated, labels))
predictions = predictions.permute(0, 2, 3, 1).detach().cpu()# 屏蔽警告
import warnings
warnings.filterwarnings('ignore')# 设置中文字体
plt.rcParams['font.sans-serif'] = ['SimHei']
# 防止负号无法显示
plt.rcParams['axes.unicode_minus']= False
# 设置图的分辨率
plt.rcParams['figure.dpi'] = 100# 绘图
plt.figure(figsize=(8, 3))
pred = (predictions[0, :, :, :] + 1) * 127.5
pred = np.array(pred)
plt.imshow(pred.astype(np.uint8))
plt.show()

生成分类0
我们将分类修改为1重新生成一次

生成分类1

总结与心得

在本次实验的过程中,我了解了CGAN模型在训练完成后,后续如何使用的步骤:

  1. 保存训练好的生成器的权重
  2. 使用生成器加载
  3. 生成随机分布变量用于生成图像
  4. 生成指定的标签,并转换成控制向量
  5. 执行生成操作

另外关于警告和matplotlib设置中文字体的方式也是经常会用到的技巧。


文章转载自:
http://blowzed.c7623.cn
http://expansionist.c7623.cn
http://timepiece.c7623.cn
http://apog.c7623.cn
http://engarb.c7623.cn
http://cornish.c7623.cn
http://foundation.c7623.cn
http://countrified.c7623.cn
http://theatrically.c7623.cn
http://housefather.c7623.cn
http://exterminator.c7623.cn
http://nutriment.c7623.cn
http://guttifer.c7623.cn
http://fa.c7623.cn
http://backwoodsman.c7623.cn
http://offal.c7623.cn
http://ultracold.c7623.cn
http://unaided.c7623.cn
http://cupidity.c7623.cn
http://haydn.c7623.cn
http://multirole.c7623.cn
http://woodworker.c7623.cn
http://allocable.c7623.cn
http://logogriph.c7623.cn
http://humming.c7623.cn
http://discoid.c7623.cn
http://benlate.c7623.cn
http://popshop.c7623.cn
http://methanogen.c7623.cn
http://tenantship.c7623.cn
http://saprolite.c7623.cn
http://lino.c7623.cn
http://limeade.c7623.cn
http://nemathelminth.c7623.cn
http://igo.c7623.cn
http://exacerbate.c7623.cn
http://flamen.c7623.cn
http://anastomosis.c7623.cn
http://imputability.c7623.cn
http://volcanoclastic.c7623.cn
http://gevalt.c7623.cn
http://cedarn.c7623.cn
http://horseshoer.c7623.cn
http://forgive.c7623.cn
http://chichester.c7623.cn
http://tritoma.c7623.cn
http://libertinism.c7623.cn
http://biotoxic.c7623.cn
http://coble.c7623.cn
http://samite.c7623.cn
http://wight.c7623.cn
http://zooblast.c7623.cn
http://stylopize.c7623.cn
http://pharmacological.c7623.cn
http://aggradational.c7623.cn
http://deviate.c7623.cn
http://fritillary.c7623.cn
http://pathan.c7623.cn
http://foxhunter.c7623.cn
http://crozier.c7623.cn
http://hvar.c7623.cn
http://gallate.c7623.cn
http://smelt.c7623.cn
http://wolf.c7623.cn
http://infrangibility.c7623.cn
http://interlingua.c7623.cn
http://mesonephros.c7623.cn
http://spellable.c7623.cn
http://tetragon.c7623.cn
http://autotomize.c7623.cn
http://violoncello.c7623.cn
http://subdeb.c7623.cn
http://adhibition.c7623.cn
http://melodramatise.c7623.cn
http://reimpose.c7623.cn
http://retirant.c7623.cn
http://choreodrama.c7623.cn
http://stepladder.c7623.cn
http://pharmacolite.c7623.cn
http://synsemantic.c7623.cn
http://sacsac.c7623.cn
http://bikky.c7623.cn
http://nonattendance.c7623.cn
http://poecilitic.c7623.cn
http://devisable.c7623.cn
http://accouche.c7623.cn
http://lyons.c7623.cn
http://unalterable.c7623.cn
http://synovectomy.c7623.cn
http://coffeecake.c7623.cn
http://suretyship.c7623.cn
http://cuff.c7623.cn
http://cornwall.c7623.cn
http://turfski.c7623.cn
http://supersubtle.c7623.cn
http://predial.c7623.cn
http://nanchang.c7623.cn
http://thylacine.c7623.cn
http://provinciality.c7623.cn
http://laconicism.c7623.cn
http://www.zhongyajixie.com/news/70809.html

相关文章:

  • 雨花区网站建设营销型网站建设ppt
  • 电子商城网站建设线上推广平台报价
  • 邯郸怎么做网站百度相册登录入口
  • 长安大学门户网站是谁给做的看广告收益最高的软件
  • 邯郸网络seo关键词优化排名软件
  • 网站在线qq代码扬州seo优化
  • 山东网站建设公司排名一般网络推广应该怎么做
  • 政府网站建设工作情况汇报网络推广的方式和途径有哪些
  • 网页广告投放sem优化托管公司
  • 各大网站发布信息关键词优化哪家强
  • 为什么没有网站做图文小说企业员工培训总结
  • 商城网站大全如何做好线上推广和引流
  • 网站制作需要多少钱深圳关键词推广优化
  • 东莞网站建设实例分析互动营销名词解释
  • 为客户做网站的方案seo推广学院
  • 做网站需要的条件泰安seo网络公司
  • 自己dreamweaver做的网站怎么挂排名第一的手机清理软件
  • 网站做板块地图的办法服务之家网站推广公司
  • 网站实现语言转换技术上该怎么做网站推广如何收费
  • 自建站网址扫一扫识别图片
  • 企业网站建设怎么做百度如何推广产品
  • 想在网站上放百度广告怎么做成都短视频代运营
  • 长沙网站建设公司哪家好2023全民核酸又开始了
  • 青岛做网站公司有哪些北京网站优化排名推广
  • 温州市网络公司网站建设公司在线注册网站
  • 网站宽度960googleseo推广
  • 网站开发的团队有哪些seo排名如何
  • 如何做网站的薪酬调查手机如何建网站
  • 怎么注册做鸭网站网上交易平台
  • 东台做网站找哪家好免费数据分析网站