大数据开发之keras代码框架应用
总体来讲keras这个深度学习框架真的很“简易”,它体现在可参考的文档写的比较详细,不像caffe,装完以后都得靠技术博客,keras有它自己的官方文档(不过是英文的),这给初学者提供了很大的学习空间。
在此做下代码框架应用笔记
class VGGNetwork:
def append_vgg_network(self, x_in, true_X_input):
return x #x is output of VGG
def load_vgg_weight(self, model):
return model
class DiscriminatorNetwork:
def append_gan_network(self, true_X_input):
return x
class GenerativeNetwork:
def create_sr_model(self, ip):
return x
def get_generator_output(self, input_img, srgan_model):
return self.output_func([input_img])
class SRGANNetwork:
def build_srgan_pretrain_model(self):
return self.srgan_model_
def build_discriminator_pretrain_model(self):
return self.discriminative_model_
def build_srgan_model(self):
return self.srgan_model_
def pre_train_srgan(self, image_dir, nb_images=50000, nb_epochs=1, use_small_srgan=False):
for i in range(nb_epochs):
for x in datagen.flow_from_directory
if iteration % 50 == 0 and iteration != 0
validation//print psnr
Train only generator + vgg network
if iteration % 1000 == 0 and iteration != 0
Saving model weights
def pre_train_discriminator(self, image_dir, nb_images=50000, nb_epochs=1, batch_size=128):
for i in range(nb_epochs):
for x in datagen.flow_from_directory
Train only discriminator
if iteration % 1000 == 0 and iteration != 0
Saving model weights
def train_full_model(self, image_dir, nb_images=50000, nb_epochs=10):
for i in range(nb_epochs):
for x in datagen.flow_from_directory
if iteration % 50 == 0 and iteration != 0
validation//print psnr
if iteration % 1000 == 0 and iteration != 0
Saving model weights
Train only discriminator, disable training of srgan
Train only generator, disable training of discriminator
if __name__ == "__main__":
from keras.utils.visualize_util import plot # Path to MS COCO dataset
coco_path = r"D:\Yue\Documents\Dataset\coco2014\train2014" '''
Base Network manager for the SRGAN model Width / Height = 32 to reduce the memory requirement for the discriminator. Batch size = 1 is slower, but uses the least amount of gpu memory, and also acts as
Instance Normalization (batch norm with 1 input image) which speeds up training slightly.
''' srgan_network = SRGANNetwork(img_width=32, img_height=32, batch_size=1)
srgan_network.build_srgan_model()
#plot(srgan_network.srgan_model_, 'SRGAN.png', show_shapes=True) # Pretrain the SRGAN network
#srgan_network.pre_train_srgan(coco_path, nb_images=80000, nb_epochs=1) # Pretrain the discriminator network
#srgan_network.pre_train_discriminator(coco_path, nb_images=40000, nb_epochs=1, batch_size=16) # Fully train the SRGAN with VGG loss and Discriminator loss
srgan_network.train_full_model(coco_path, nb_images=80000, nb_epochs=5)
大数据开发之keras代码框架应用的更多相关文章
- .NET Web开发之.NET MVC框架
摘要:MVC是一种架构设计模式,该模式主要应用于图形化用户界面(GUI)应用程序.那么什么是MVC?MVC由三部分组成:Model(模型).View(视图)及Controller(控制器). MVC概 ...
- Android开发之Drag&Drop框架实现拖放手势
Android3.0提供了drag/drop框架,利用此框架可以实现使用拖放手势将一个view拖放到当前布局中的另外一个view中.本文将介绍如何使用拖放框架. 一.实现拖放的步骤 首先,我们先了解一 ...
- 基于Python的大数据的分页模型代码
最近在写一个cmdb系统的分页,尽管Django本身有分页的模块儿,但是还是想实现一下自己心中想的分页的一种逻辑 因为,在我们工作当中,当我们的数据量超级大的时候,其实我们每次分页查询都不必将所有的数 ...
- iOS开发之HelloKit代码片段
完整代码托管:https://github.com/1042710553/HelloKit.git /************************/plist/****************** ...
- 大数据“重磅炸弹”——实时计算框架 Flink
Flink 学习 项目地址:https://github.com/zhisheng17/flink-learning/ 博客:http://www.54tianzhisheng.cn/tags/Fli ...
- Android开发之Volley网络通信框架
今天用了一下Volley网络通信框架,感觉挺好用的,写个博客记录一下用法.方便以后VC. Volley(Google提供的网络通信库,能使网络通信更快,更简单,更健壮.) 功能模块: 1. JSON, ...
- j2ee开发之Spring2.5框架学习笔记
Spring 2.5框架学习笔记 1.是一个开源的控制反转IOC和面向切面AOP的容器框架 2.IOC控制反转 public class PersonServiceBean { private Per ...
- 移动平台前端开发之WebApp代码技巧
1.首先我们来看看webkit内核中的一些私有的meta标签,这些meta标签在开发webapp时起到非常重要的作用 <meta content="width=device-width ...
- 大数据学习——hadoop的RPC框架
项目结构 服务端代码 test-hadoop-rpc pom.xml <?xml version="1.0" encoding="UTF-8"?> ...
随机推荐
- DockerFile语法【h】
DockerFile在我理解就是可以将所需要构建镜像的功能.组件都天前配置好,然后直接生成一个Image,而不是先生成镜像,再通过修改容器的方法来生成最终需要的镜像. 镜像的定值实际上就是定值每一 ...
- 关于UiAutomator无法识别的元素
1.关于没有name,没有ID的元素的定位---通用篇解题思路:因为没有name,id:其实剩下的选择已不多,要么xpath,要么className.xpath木有好印象(稳定性不高,加之1.0x后需 ...
- jiaba
- LeetCode 921. 使括号有效的最少添加(Minimum Add to Make Parentheses Valid) 48
921. 使括号有效的最少添加 921. Minimum Add to Make Parentheses Valid 题目描述 给定一个由 '(' 和 ')' 括号组成的字符串 S,我们需要添加最少的 ...
- Endpoint is unreachable and there is no snapshot available for offline browsing
docker Portainer配置的时候出现这个错误:Endpoint is unreachable and there is no snapshot available for offline b ...
- Elasticsearch进阶篇(一)~head插件的安装与配置
1.安装node.js 1.1.通过官网下载二进制安装包 https://nodejs.org/en/download/ 选择对应的版本,右键复制下载链接,进入linux目录,切换到要安装目录的磁盘. ...
- vue中引入百度地图
xxx.vue <template> <div> <el-input v-model="inputaddr"> </el-input> ...
- Locust性能测试-环境准备与基本使用 转自:悠悠
前言 提到性能测试,大部分小伙伴想到的就是LR和jmeter这种工具,小编一直不太喜欢写这种工具类的东西,我的原则是能用代码解决的问题,尽量不去用工具. python里面也有一个性能测试框架Locus ...
- SnowflakeIdWorker
/** * Twitter_Snowflake<br> * SnowFlake的结构如下(每部分用-分开):<br> * 0 - 0000000000 0000000000 0 ...
- 使用 EnumWindows 找到满足你要求的窗口
原文:使用 EnumWindows 找到满足你要求的窗口 在 Windows 应用开发中,如果需要操作其他的窗口,那么可以使用 EnumWindows 这个 API 来枚举这些窗口. 本文介绍使用 E ...